Skip to content

Instantly share code, notes, and snippets.

@talayhan
Forked from lifuzu/gitemail
Created April 2, 2021 12:59
Show Gist options
  • Select an option

  • Save talayhan/d67a67ae04140bb6534252b19ea48ed3 to your computer and use it in GitHub Desktop.

Select an option

Save talayhan/d67a67ae04140bb6534252b19ea48ed3 to your computer and use it in GitHub Desktop.
Update email and user name in the git history
git filter-branch -f --commit-filter '
if [ "$GIT_AUTHOR_EMAIL" = "origin@email.address" -o "$GIT_AUTHOR_EMAIL" = "origin2@email.address" ];
then
GIT_AUTHOR_NAME="User Name";
GIT_AUTHOR_EMAIL="new@mail.address";
git commit-tree "$@";
else
git commit-tree "$@";
fi' HEAD
# Reference:
# http://git-scm.com/book/en/Git-Tools-Rewriting-History
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment