Skip to content

Instantly share code, notes, and snippets.

@topalex
Created June 21, 2021 15:26
Show Gist options
  • Save topalex/15925222a69be8a61a21a0117b9f16f9 to your computer and use it in GitHub Desktop.
Save topalex/15925222a69be8a61a21a0117b9f16f9 to your computer and use it in GitHub Desktop.
Fix wrong emails in git history
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="root@localhost.localdomain"
CORRECT_NAME="Alex.Top"
CORRECT_EMAIL="topalex92@gmail.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
' -f --tag-name-filter cat -- --branches --tags
git push --force --tags origin 'refs/heads/*'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment