Skip to content

Instantly share code, notes, and snippets.

@sauloefo
Created January 2, 2019 21:10
Show Gist options
  • Save sauloefo/0a89dd32f1c49ed56ec7fcc648d4c255 to your computer and use it in GitHub Desktop.
Save sauloefo/0a89dd32f1c49ed56ec7fcc648d4c255 to your computer and use it in GitHub Desktop.
Change the username and email of all commits that match the value of OLD_EMAIL var.
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="put old email here"
CORRECT_NAME="put new name here"
CORRECT_EMAIL="put new email here"
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