Skip to content

Instantly share code, notes, and snippets.

@vincenavarro
Forked from octocat/git-author-rewrite.sh
Last active February 3, 2019 19:47
Show Gist options
  • Save vincenavarro/afe6eb886c1626bbeadd753a03caca6c to your computer and use it in GitHub Desktop.
Save vincenavarro/afe6eb886c1626bbeadd753a03caca6c to your computer and use it in GitHub Desktop.
Mutli-email replacement for git commits.
#!/bin/sh
git filter-branch -f --env-filter $'
OLD_EMAILS="
oldaddress1@gmail.com
oldaddress2@gmail.com
"
CORRECT_NAME="New Name"
CORRECT_EMAIL="newname@gmail.com"
for EMAIL in ${OLD_EMAILS}; do
if [ "$GIT_COMMITTER_EMAIL" = "$EMAIL" ]; then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$EMAIL" ]; then
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
done
' --tag-name-filter cat -- --branches --tags
#git push --force --tags origin 'refs/heads/*'
#from https://help.github.com/articles/changing-author-info/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment