Skip to content

Instantly share code, notes, and snippets.

@kogakure
Created October 9, 2009 07:28
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kogakure/205825 to your computer and use it in GitHub Desktop.
Save kogakure/205825 to your computer and use it in GitHub Desktop.
Bash: Git – Rename an email address in all old commits.
# Rename an email address in all old commits.
# WARNING: Will change all your commit SHA1s.
# Based off of the script from here:
# http://coffee.geek.nz/how-change-author-git.html
git filter-branch -f --commit-filter '
if [ "$GIT_COMMITTER_EMAIL" = "joern.zaefferer@googlemail.com" ];
then
GIT_AUTHOR_EMAIL="joern.zaefferer@gmail.com";
GIT_COMMITTER_EMAIL="joern.zaefferer@gmail.com";
git commit-tree "$@";
else
git commit-tree "$@";
fi' HEAD
git push --force
@strugee
Copy link

strugee commented Apr 10, 2015

I had to change $GIT_COMMITTER_EMAIL to $GIT_AUTHOR_EMAIL to get this to work.

@v6
Copy link

v6 commented Dec 14, 2016

// , This is the first result for [batch change email address in all commits git(https://duckduckgo.com/?q=batch+change+email+address+in+all+commits+git).

Well done.

Why does this "change all your commit SHA1s", though?

@antonkatz
Copy link

Doesn't work. Deletes all commits.
That git push --force is a terrible idea to put into an automatic script that can delete all your commits

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