Skip to content

Instantly share code, notes, and snippets.

@nash403
Created May 18, 2017 08:08
Show Gist options
  • Save nash403/1028383da7394b1ae2c79e13259f8775 to your computer and use it in GitHub Desktop.
Save nash403/1028383da7394b1ae2c79e13259f8775 to your computer and use it in GitHub Desktop.
Changing the Git history to change the author of commits. Copy paste, replace OLD_EMAIL, CORRECT_NAME & CORRECT_EMAIL and press ENTER.
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.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
' --tag-name-filter cat -- --branches --tags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment