How to change the commit author for one specific commit?

后端 未结 19 1887
没有蜡笔的小新
没有蜡笔的小新 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:41

    If the commit that you want to change is not the last commit, then follow the below steps. If your commit is in different branch then first switch to that branch.

    git checkout branch_name

    Find commit before the commit that you want to change and find its hash. Then issue rebase command.

    git rebase -i -p hash of commit

    Then an editor will open and enter 'edit' for the commits that you want to change. Leave others with default 'pick' option. Once changed enter 'esc' key and wq! to exit.

    Then issue git commit command with amendment option.

    git commit --amend --author="Username email" --no-edit

    Then issue the following command.

    git rebase --continue

    Once commit author is updated in the local repository, push the changes to the remote repository.

提交回复
热议问题