How to change the commit author for one specific commit?

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

    Commit before:

    To fix author for all commits you can apply command from @Amber's answer:

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

    Or to reuse your name and email you can just write:

    git commit --amend --author=Eugen
    

    Commit after the command:

    For example to change all starting from 4025621:

    You must run:

    git rebase --onto 4025621 --exec "git commit --amend --author=Eugen" 4025621
    

    Note: To include an author containing spaces such as a name and email address, the author must be surrounded by escaped quotes. For example:

    git rebase --onto 4025621 --exec "git commit --amend --author=\"Foo Bar \"" 4025621
    

    or add this alias into ~/.gitconfig:

    [alias]
        reauthor = !bash -c 'git rebase --onto $1 --exec \"git commit --amend --author=$2\" $1' --
    

    And then run:

    git reauthor 4025621 Eugen
    

提交回复
热议问题