Git: Resetting the author for previous commits

Today I made a few commits on a system where several developers share the same system user. After several commits I noticed that the git author (git.name and git.email) was set to someone else globally.

Git allows to set these configuration values locally using

git config user.name "Your Name"
git config user.email "your.name@example.com"

To change previous commits Stack Overflow users had several solutions.

The most simple one, which only works for the last commit is

git commit --amend --reset-author --no-edit

Which uses the newly set author configuration from above to amend the previous commit.

I needed to do it for two commits, so I had to use the rebasing solution:

git rebase --onto HEAD~2 --exec "git commit --amend --reset-author --no-edit" HEAD~2

which does amendment for every commit after HEAD~2 (the grandparent of HEAD). Nice and easy :-).



Home