1

So... not sure how it happened, but I had been working in a branch a I made a couple changes, ran git add -A and then git commit (with a comment). Did that a few times, and then when I went to push up all the changes to the branch I was in, I got a message that said that the branch was already up to date. I couldnt figure out what the heck was going on, so I checked back out the branch and it overwrote everything.

Stranger still, now all the commits I made are gone when I run git log.

Any way I can get it all back? Or am I SOL and have to figure out why the heck it kicked me out of my branch for some reason?

Titus P
  • 959
  • 1
  • 7
  • 16

1 Answers1

1

You are in a detached HEAD (see "Why did my Git repo enter a detached HEAD state?").
You can confirm it with a git status.

Simply start by making a branch where you are:

git branch tmp

See here one way to fix it (and keeping your commits), if you want to push aBranch:

git checkout aBranch
git merge tmp

aBranch should now include the commits you did, and you should be able to push it.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • That was exactly right, with a caveat that somehow I was in a detached head of an entirely different branch than the one I had checked out last. I have on idea how these things happen -_- Thanks for the help! – Titus P Jun 15 '14 at 05:25