21

I was trying something out with a couple of branches so I rebased on a temporary branch and was in the middle of resolving some conflicts when I decided to not to complete the rebase it out another way. I then deleted the temporary branch involved and went on my merry way. A couple of hours later I wanted to rebase another branch and get this error message

Interactive rebase already started

git rebase --abort displays this error message

error: unable to resolve reference refs/heads/tmp/rails3-rails-2-fixes: No such file or directory
fatal: Cannot lock the ref 'refs/heads/tmp/rails3-rails-2-fixes'.
Could not move back to refs/heads/tmp/rails3-rails-2-fixes

Tried to just create another branch named tmp/rails3-rails-2-fixes but no dice

Any ideas how I can resolve this?

Mark Longair
  • 446,582
  • 72
  • 411
  • 327
tee
  • 725
  • 2
  • 8
  • 15

3 Answers3

20

Hm, that's awkward. Recreating the branch would've been my first try too. Failing that, you should be able to remove the .git/rebase-merge directory, which contains the rebase state. (Move it to the side instead to be safe, if you want.) Once that's gone, Git shouldn't have any way to know there was a rebase in progress. Have a look at your branches to make sure you haven't managed to lose any commits in the process, and you'll be good!

Cascabel
  • 479,068
  • 72
  • 370
  • 318
  • 1
    That worked and so far I can't see any missing commits, thanks alot you've saved me alot of hassle :D – tee Jan 17 '12 at 17:10
10

check the git status and see if you not checkout any branch after last rebase then you are not on any branch.

becase rebase transfer you to a non branch area, so you have to abort the last rebase by using git rebase --abort command and checkout a branch to go on the branch and start new rebasing

Dau
  • 8,578
  • 4
  • 23
  • 48
  • I've been able to checkout other branches since, which is one of the reasons why I didn't notice until I tried to rebase another branch – tee Jan 17 '12 at 14:13
  • yes you can able to checkout the branch any time. but this is the git functionality, it will not warn when you checkout about rebasing. but git warn about the continue and abort option when conflict occurs – Dau Jan 17 '12 at 14:15
  • I already git rebase --abort but received the error message above, any other possible solutions? – tee Jan 17 '12 at 14:23
  • use the git status and see any extra files is there then removed them, and use git reset --hard HEAD to remove the rebase header – Dau Jan 17 '12 at 14:30
  • i'm on a completely different branch, the branch which the rebase occurred on is deleted so I'm not sure thats going to work – tee Jan 17 '12 at 14:37
  • `git rebase --abort` Wonderful :D – Ariful Haque May 11 '17 at 02:10
1

I just got a very similar error during an attempted rebase that did not fail. None of the tips above helped. Here's what I was seeing:

$ git pull --rebase
warning: refname 'xport1' is ambiguous.
First, rewinding head to replay your work on top of it...
Fast-forwarded xport1 to 98b787b0ea1f7f6771a5b1b56c7e8cc67b84c242.
error: Ref refs/heads/xport1 is at 98b787b0ea1f7f6771a5b1b56c7e8cc67b84c242 but expected 3865d63ffb3a1a495363bfbd9ebb089e16152839
fatal: Cannot lock the ref 'refs/heads/xport1'.
Could not move back to refs/heads/xport1

It turns out that if a reference name is ambigious, the rebase will fail, at least on git version 1.7.10.2 (Apple Git-33). I poked around and saw I had accidentally created a tag with the same name as the branch I was trying to rebase on. Deleting the tag got rid of this error.

Eliot
  • 5,450
  • 3
  • 32
  • 30