git – Change commit author at one specific commit – Stack Overflow
Posted by jpluimers on 2020/09/22
Every now and then I forget to git config --local user.name
and git config --local user.email
, so git takes my global settings and I need to fix one or more commits to it shows the correct author
.
For the last commit, when not yet pushed, this is easy:
git commit --amend --author="Author Name <email@address.com>"
For historic commits, or when you already pushed, it gets far more difficult, so I am glad there is a good set of steps at [WayBack] git – Change commit author at one specific commit – Stack Overflow.
For now in my %USERPROFILE%\.gitconfig
file, I have added entries for various accounts so it is easier to spot them with git config --list --global
then edit them using git config --edit --local
:
[user.foo] name = jeroenfo email = ########+jeroenfoo@users.noreply.github.com [user.gh] name = Jeroen Wiert Pluimers email = jeroen.vvv.www@pluimers.com [user.gl] name = Jeroen Wiert Pluimers email = jeroen.xxx.yyy@pluimers.com
If you pushed, but nobody pulled, and you are the only one committing, then the steps are like this if your git is 1.8 or higher:
- Once,
- perform
git rebase -i --root
- at all commits you want to edit, change
pick
intoedit
- write the file, then leave the editor (
:wq
)
- perform
- For each commit, until git indicates
No rebase in progress?
:- perform
git commit --amend --reset-author --no-edit
- perform
git rebase --continue
- perform
–jeroen
Leave a Reply