Skip to content

Instantly share code, notes, and snippets.

@MattRyanCo
Created August 24, 2018 19:52
Show Gist options
  • Save MattRyanCo/f3bf160956a359a2423c3081ae03be29 to your computer and use it in GitHub Desktop.
Save MattRyanCo/f3bf160956a359a2423c3081ae03be29 to your computer and use it in GitHub Desktop.
Replace / rewrite incorrect author email with correct
git filter-branch --env-filter '
OLD_EMAIL="matt@capwebsolutions.com"
CORRECT_NAME="Matt Ryan"
CORRECT_EMAIL="matt@web-savvy-marketing.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
@MattRyanCo
Copy link
Author

MattRyanCo commented Aug 24, 2018

Execute this using a CygWin Bash command prompt (access via context menu - right click).

You should be at the top level folder - the same folder that has the .git repo in it.

CygWin Bash It permits multi-line pasting a little easier. When script is pasted you will be left with cursor sitting at the end of the --tags line. Hit enter and wait.

You will see a line like this:
Rewrite 600aafceb35f0349d3b072d04328c3f782878e7c (22/22) (57 seconds passed, remaining 0 predicted)

The line will be updated several times as the repo changes are applied.

Once completed, push force the changes to GitHub:
git push --force --tags origin 'refs/heads/*'

All should be good now with repo.

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