Recently, I needed to change the email address on all commits in most of my personal git repos.
Searching on the web, there are a few methods of doing this, most
git rebase. There are also some that use
git-filter-branch puts out a
warning/recommendarion to use
git-filter-repo instead, which is what
I ended up doing in the end.
Important to note, that all of these methods will rewrite the whole commit history, and change all the hashes. Since, I am the sole committer here, I wasn’t too much concered about that. Needless to say, take backups!
git-filter-repo is not included in a standard git package. It is
available on most Linux distributions though.
# Arch Linux pacman -S git-filter-repo # OpenSUSE zypper install git-filter-repo
Before doing anything, taking a full backup of the repo is a must!
# clone a temporary fresh bare repository git clone --bare <repo> # change the email and name on all commits git filter-repo \ --email-callback 'return b"firstname.lastname@example.org"' \ --name-callback 'return b"testname"' # push with force git push --force # remove temporary repo rm -rf <repo> # clone the fixed repo git clone <repo>