How to change the author and committer name and e-mail of multiple commits in Git?

后端 未结 30 3154
野性不改
野性不改 2020-11-21 04:50

I was writing a simple script in the school computer, and committing the changes to Git (in a repo that was in my pendrive, cloned from my computer at home). After several c

30条回答
  •  借酒劲吻你
    2020-11-21 05:13

    Note that git stores two different e-mail addresses, one for the committer (the person who committed the change) and another one for the author (the person who wrote the change).

    The committer information isn't displayed in most places, but you can see it with git log -1 --format=%cn,%ce (or use show instead of log to specify a particular commit).

    While changing the author of your last commit is as simple as git commit --amend --author "Author Name ", there is no one-liner or argument to do the same to the committer information.

    The solution is to (temporarily, or not) change your user information, then amend the commit, which will update the committer to your current information:

    git config user.email my_other_email@example.com 
    git commit --amend
    

提交回复
热议问题