Skip to content

Instantly share code, notes, and snippets.

@blesson3
Created July 10, 2017 21:16
Show Gist options
  • Save blesson3/2fcc9e0d635d25a0f0e94cf13f9687fb to your computer and use it in GitHub Desktop.
Save blesson3/2fcc9e0d635d25a0f0e94cf13f9687fb to your computer and use it in GitHub Desktop.
Changes an author on all commits using a bad/old email address
# WARNING: rewrites all commits (different SHAs)
$ git filter-branch -f --env-filter '
WRONG_EMAIL="bad@email.com"
NEW_NAME="username"
NEW_EMAIL="good@email.com"
if [ "$GIT_COMMITTER_EMAIL" = "$WRONG_EMAIL" ]
then
export GIT_COMMITTER_NAME="$NEW_NAME"
export GIT_COMMITTER_EMAIL="$NEW_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$WRONG_EMAIL" ]
then
export GIT_AUTHOR_NAME="$NEW_NAME"
export GIT_AUTHOR_EMAIL="$NEW_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags
@blesson3
Copy link
Author

-f => force overwrite an existing backup (not needed when using only once)

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