Git rebase failing

Bunker picture Bunker · Jan 9, 2016 · Viewed 25.9k times · Source

I'm trying to rebase the work of a colleague.

First, I get a ton of conflicts where <<<<< head seams to contain the new code.

Then after a while I get the following error:

fatal: update_ref failed for ref 'refs/heads/dev_504': 
cannot lock ref     'refs/heads/dev_504': ref refs/heads/dev_504 is at
 XXXXXXX 
 but expected     XXXXXXXX
Could not move back to refs/heads/dev_504

Then if I try to continue anyway I get the following error:

fatal: cannot resume: .git/rebase-apply/final-commit does not exist.

How can I fix this so the rebase won't give an error?

Answer

Slim KTARI picture Slim KTARI · Aug 24, 2017
  • You can run git rebase --abort to completely undo the rebase. Git will return you to your branch's state as it was before git rebase was called.

  • You can run git rebase --skip to completely skip the commit. That means that none of the changes introduced by the problematic commit will be included. It is very rare that you would choose this option.

  • You can fix the conflict.

  • Failing that, you should re-create your branch or you can be able to remove the .git/rebase-merge directory, which contains the rebase state.