Skip to content

Instantly share code, notes, and snippets.

@sadovnik
Created February 17, 2017 18:59
Show Gist options
  • Save sadovnik/7614ed390a7f1db38abe520a1b5eb609 to your computer and use it in GitHub Desktop.
Save sadovnik/7614ed390a7f1db38abe520a1b5eb609 to your computer and use it in GitHub Desktop.
Git: replace commit author name and email on every commit that matches
git filter-branch --env-filter '
oldname="Cyril"
oldemail="old.email@example.com"
newname="Cyril Sadovnik"
newemail="new.email@example.com"
[ "$GIT_AUTHOR_EMAIL" = "$oldemail" ] && GIT_AUTHOR_EMAIL="$newemail"
[ "$GIT_COMMITTER_EMAIL" = "$oldemail" ] && GIT_COMMITTER_EMAIL="$newemail"
[ "$GIT_AUTHOR_NAME" = "$oldname" ] && GIT_AUTHOR_NAME="$newname"
[ "$GIT_COMMITTER_NAME" = "$oldname" ] && GIT_COMMITTER_NAME="$newname"
' head
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment