How to change the commit author for one specific commit?

后端 未结 19 2148
没有蜡笔的小新
没有蜡笔的小新 2020-11-22 05:15

I want to change the author of one specific commit in the history. It\'s not the last commit.

I know about this question - How do I change the author of a commit in

19条回答
  •  一整个雨季
    2020-11-22 05:45

    You can change author of last commit using the command below.

    git commit --amend --author="Author Name "

    However, if you want to change more than one commits author name, it's a bit tricky. You need to start an interactive rebase then mark commits as edit then amend them one by one and finish.

    Start rebasing with git rebase -i. It will show you something like this.

    https://monosnap.com/file/G7sdn66k7JWpT91uiOUAQWMhPrMQVT.png

    Change the pick keyword to edit for the commits you want to change the author name.

    https://monosnap.com/file/dsq0AfopQMVskBNknz6GZZwlWGVwWU.png

    Then close the editor. For the beginners, hit Escape then type :wq and hit Enter.

    Then you will see your terminal like nothing happened. Actually you are in the middle of an interactive rebase. Now it's time to amend your commit's author name using the command above. It will open the editor again. Quit and continue rebase with git rebase --continue. Repeat the same for the commit count you want to edit. You can make sure that interactive rebase finished when you get the No rebase in progress? message.

提交回复
热议问题