1

I deleted my active branch in GitX, and now I can't seem to get out of it in the terminal.

When I try to check out any other branch, it tells me I have unstashed changes -- but I can't stash them (I get "fatal: bad revision 'HEAD'").

I've tried to re-create the branch, but then I get "fatal: You are on a branch yet to be born"

And I've tried to merely check out the branch, but of course, since it's deleted, I can't.

How can I get un-stuck?

jawns317
  • 1,726
  • 2
  • 17
  • 26
  • Have you tried a `git reset --hard HEAD`? That would delete all the unstashed changes, if I'm right. – Fred Foo Jan 18 '12 at 20:09
  • 1
    Yes, I tried. Got: "fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree." – jawns317 Jan 18 '12 at 20:11

2 Answers2

1

I faced the same issue. When I was trying to checkout to other branch I got Please commit your changes or stash them before you switch branches. message. I did a sample commit on a local branch (which is already deleted) but did not push the changes. And then I was able to checkout to some other branch. Now you can delete the local branch.

Shrikant Shete
  • 319
  • 2
  • 11
0

git reset --hard [SHA of previous master commit]

jawns317
  • 1,726
  • 2
  • 17
  • 26