The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 4,184 other subscribers

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 [WayBackgit – 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:

  1. Once,
    1. perform git rebase -i --root
    2. at all commits you want to edit, change pick into edit
    3. write the file, then leave the editor (:wq)
  2. For each commit, until git indicates No rebase in progress?:
    1. perform git commit --amend --reset-author --no-edit
    2. perform git rebase --continue

–jeroen

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: