Sometimes you accidentally commit code under the wrong author or committer credentials. This has happened to me a few times while writing code from computers with global git settings. By using `git filter-branch` it is possible to rewrite history… muhahahah!
This snippet will run through your branch’s historical commits and rename the author and committer attributes.
It basically looks for all commits containing a given `$OLD_EMAIL` and resets the following properties:
- GIT_AUTHOR_NAME
- GIT_AUTHOR_EMAIL
- GIT_COMMITTER_NAME
- GIT_COMMITTER_EMAIL
The code:
This code is an updated version of the “nuclear option” code provided in the ProGit book.
Finally just push:
git push --force --tags origin 'refs/heads/*'