Skip to content

Instantly share code, notes, and snippets.

@tutumagi
Last active December 2, 2022 03:06
Show Gist options
  • Save tutumagi/3d1761ac4e921d525cf98a399a99f770 to your computer and use it in GitHub Desktop.
Save tutumagi/3d1761ac4e921d525cf98a399a99f770 to your computer and use it in GitHub Desktop.
modify commit usr #git
#!/bin/sh
## 1. git clone --bare your_git_repo
## 2. modify the script below
## 3. git push --force --tags origin 'refs/heads/*'
## 4. remove your temp git_repo dir
git filter-branch --env-filter '
OLD_EMAIL="[email protected]"
CORRECT_NAME="lisi"
CORRECT_EMAIL="[email protected]"
# 可以通过或关系重写多个用户名
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment