How do I git rebase the first commit?

前端 未结 1 1410
南方客
南方客 2020-12-04 07:35

I used git init to create a fresh repo, then made three commits. Now I want to rebase to go back and amend my first commit, but if I do git rebase -i HEAD

相关标签:
1条回答
  • 2020-12-04 08:05

    The easy way, with a recent-enough git (this has been out for a long time now so you should have this):

    git rebase -i --root
    

    The other easy way, as twalberg noted in a comment, is to use git checkout --orphan to set up to make a new root commit, which you can copy the old commits on top of. (This is what rebase -i --root ends up doing internally anyway.)

    0 讨论(0)
提交回复
热议问题