1

I did:

git reset --soft ^HEAD

when I guess I really meant:

git reset --soft HEAD

Now all of my day's work is "gone". Is it possible to move back up the ladder to capture what I did today

The reason I did the reset is because I initially did:

git commit -a -m "xyz"

instead of:

git commit -m "xyz"
talles
  • 14,356
  • 8
  • 45
  • 58
RubyRedGrapefruit
  • 12,066
  • 16
  • 92
  • 193
  • Have you tried [this](http://stackoverflow.com/questions/2510276/undoing-git-reset) or [this](http://stackoverflow.com/questions/5473/undoing-a-git-reset-hard-head1)? – Luís Ramalho Apr 02 '13 at 21:01
  • Yes. But unfortunately, when I take that action it shows my changes in REVERSE! So my code is *somewhere* in git, just not where I need it. I guess there's no way to put the genie back in the bottle with git, at least not without being a computer scientist. – RubyRedGrapefruit Apr 02 '13 at 21:11

2 Answers2

4

git reflog is the safety net surrounding all the wonderful git craziness. You can use it to locate the hash of your commit previous to your "undo", check that out to a branch (to be safe) and then restore your working tree from there.

More details here

Nick Tomlin
  • 28,402
  • 11
  • 61
  • 90
  • It appears I was downvoted without a comment. I'd appreciate the feedback if there is a better way to do things : ) – Nick Tomlin Apr 05 '13 at 21:27
0

Use git-reflog:

git reflog
# find SHA of commit which you "lost"
git reset --hard SHA

Finding the exact commit may be tricky, but you can inspect each commit in the reflog with git show.

brianz
  • 7,268
  • 4
  • 37
  • 44
  • I initially did a "git reset --soft". I have managed to sort of get back to where I can "see" my changes, but they are all backwards. In other words, they aren't in the files. "git status" shows my next commit as basically undoing everything I had before. – RubyRedGrapefruit Apr 02 '13 at 21:15
  • 1
    Provided that you added your changes to git at some point, you will be able to see them in the reflog (assuming gc hasn't run). Every time you do a commit or add, the reflog moves forward...so you should always be able to get back to where you once were. – brianz Apr 02 '13 at 22:25