Skip to content

Instantly share code, notes, and snippets.

@jxu
Created July 23, 2022 00:20
Show Gist options
  • Save jxu/d947684ef28da836697580ee71f2aa92 to your computer and use it in GitHub Desktop.
Save jxu/d947684ef28da836697580ee71f2aa92 to your computer and use it in GitHub Desktop.
# https://help.github.com/articles/changing-author-info/
git filter-branch --env-filter '
OLD_EMAIL="[email protected]"
CORRECT_NAME="jxu"
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
# Review history before pushing!
git push --force --tags origin 'refs/heads/*'
@jxu
Copy link
Author

jxu commented Jul 23, 2022

git rebase -r --root --exec 'git commit --amend --no-edit --author "jxu <[email protected]>"'

preserves author-date but not commit-date (https://stackoverflow.com/questions/28536980/git-change-commit-date-to-author-date)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment