Git - Change author of entire repo history
If in the past you have accidentally made commits to a repo without properly configuring the git username and user email this article is for you.
This only applies if you are the only author in a repo. Otherwise, slightly more complicated logic will be required. If I come across an instance when I need to do this I will update this article.
The following command will update every commit from the root commit:
git rebase \
--root \
--exec 'git commit --amend --author="USERNAME <USEREMAIL>" --no-edit'
To do this from a particular commit onwards (note this doesn’t include the commit specified, only everything after it), remove the --root
flag and add the commit hash to the end of the command:
git rebase --exec 'git commit --amend --author="USERNAME <USEREMAIL>" --no-edit' COMMIT_HASH