Skip to content

Instantly share code, notes, and snippets.

@OhIAmFine
Last active December 18, 2023 16:26
Show Gist options
  • Save OhIAmFine/14de458c67f846e043db9ada65b01661 to your computer and use it in GitHub Desktop.
Save OhIAmFine/14de458c67f846e043db9ada65b01661 to your computer and use it in GitHub Desktop.
change commit author in git
#!/bin/sh
git filter-branch -f --env-filter '
OLD_EMAIL="xxx.com"
CORRECT_NAME="OhIAmFine"
CORRECT_EMAIL="845782625@qq.com"
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