Edit the root commit in Git?

前端 未结 5 1250
予麋鹿
予麋鹿 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:13

    Just to provide an alternative to the higher rated answers:

    If you are creating a repo, and know upfront that you'll be rebasing on top of its "first" real commit in the future, you can avoid this problem altogether by making an explicit empty commit at the beginning:

    git commit --allow-empty -m "Initial commit"
    

    and only then start doing "real" commits. Then you can easily rebase on top of that commit the standard way, for example git rebase -i HEAD^

提交回复
热议问题