I forgot git rebase -continue and made a git commit. How to fix?

I went over the code in git, I had merge conflicts. I resolved the conflicts and did:

git add 

At the moment, I forgot to do:

 git rebase --continue 

I continued to code and did:

 git commit 

for changes. Now I am on "no branch" and cannot do:

 git rebase --continue 

How to fix it?

+96
git
Jun 23 '11 at 15:56
source share
3 answers

Change: Look at the answer below to see if this is an easier solution for you. stack overflow

I would have to try this, but I think this is what I would like to do:

  1. Tag your last commit (or just write it down SHA1 somewhere so as not to lose it): git tag temp
  2. git rebase --abort
  3. Rebase again. You will have to enable the merge again. :(
  4. git rebase --continue
  5. git cherry-pick temp

The problem is that your temp commit probably contains both merge resolution and new code. So it can be difficult, but I would try and see if it works.

+9
Jun 23 '11 at 17:23
source share

Just do git reset --soft HEAD^ . It moves the HEAD pointer to the parent, but saves the work tree and adds the merge to the index. This way you can continue the reboot with git rebase --continue , as before.

+174
Aug 28 '12 at 16:05
source share

I had the same problem, and, even worse, I went through three commits, and after resolving the conflicts on the second commit, I "fixed" instead of "rebase --continue".

As a result, I had this bastard reflog

When I applied the kirikaza solution, I just canceled the third commit, not the second one, which was problematic ..

As you can see, rebase starts by extracting from the remotes / origin / master branch and then applies my three commits, which are displayed as the three previous operations (before the extraction) in reflog.

Then, if you want to restart from a clean base, before rebasing, you can simply reset the hard hash immediately before checking the rebase operation. In my case (see Figure):

 git reset --hard 859ed3c 

Then you can start a new git rebase .

0
May 02 '19 at 13:50
source share



All Articles