Edit the root commit in Git?

前端 未结 5 1241
予麋鹿
予麋鹿 2020-11-22 16:33

There\'s ways to change the message from later commits:

git commit --amend                    # for the most recent co         


        
5条回答
  •  春和景丽
    2020-11-22 17:25

    To expand on ecdpalma's answer, you can now use the --root option to tell rebase that you want to rewrite the root/first commit:

    git rebase --interactive --root
    

    Then the root commit will show up in the rebase TODO list, and you can select to edit or reword it:

    reword  
    pick  
    ...
    

    This is the explanation of --root from the Git rebase docs (emphasis mine):

    Rebase all commits reachable from , instead of limiting them with an . This allows you to rebase the root commit(s) on a branch.

提交回复
热议问题