Forgot “git rebase --continue” and did “git commit”. How to fix?

后端 未结 4 514
耶瑟儿~
耶瑟儿~ 2020-12-07 12:39

I was rebasing code in git, I got some merge conflicts. I resolved the conflicts and did:

git add

At this point I forgot to do:

<         


        
4条回答
  •  一向
    一向 (楼主)
    2020-12-07 13:16

    I got the same problem, and to make it worse, I was rebasing three commits, and after solving conflicts on the second commit, I "committed" instead of "rebase --continue".

    As a result I had this git reflog

    When I applied kirikaza's solution, I just reverted the third commit, and not the second one, which was problematic..

    As you can see, the rebase starts by a checkout from the remotes/origin/master branch and then applies my three commits that appear as the three previous operation (before the checkout) in the reflog.

    Then, if you want to restart from a clean base, before the rebase, you can simply reset hard to the hash just before the checkout of the rebase operation. In my case (see the picture):

    git reset --hard 859ed3c
    

    Then you can start a new git rebase.

提交回复
热议问题