How to change the commit author for one specific commit?

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

    There is also a lazy approach to this problem, especially if you have more than one commit that you want to change. In my case, I had a new branch with several commits with a wrong author, so what helped me:

    Go to your original branch:

    git checkout develop
    

    Create new branch from it:

    git checkout -b myFeature develop 
    

    Merge it without commit info as one commit:

    git merge --no-commit --squash branchWrongAuthor
    

    You might also want to stage changes:

    git stage .
    

    Change the name of the author and commit changes:

    git commit --amend --author "New Author Name " -m "new feature added"
    

    And that's it, you can push the changes.

    git push
    

    You can delete the branch with a wrong author after that.

提交回复
热议问题