views:

39

answers:

2

I'm using Git Gui and Gitk on Windows. How do I undo a hard reset from within the past two hours?

(Is it possible to do this from these applications, without using the command line?)

I saw this SO post, which says that undos are possible before git's garbage collection occurs. I might have quit and reopened one or both of these applications.

A: 

I don't think you can undo a hard reset to get uncommitted changes back - you can undo a rebase because the blobs are still available, but if you never committed your newest changes to Git ever, anything it overwrote is most likely history. I'd love to find out that I'm wrong though!

Paul Betts
@Paul Betts: I did a hard reset to a commit on the day before. Can I get back those subsequent commits?
Winston C. Yang
+1  A: 

See the answers by Brian Riehman and Pat Notz in the link in the question.

One solution is to use the command line.

In Windows, open DOS in the directory containing your .git directory.

Type something like the following to see what commit you want to go to:

"c:\Program Files\Git\bin\git.exe" reflog

To go to a certain commit, type something like the following, where the last expression is the SHA1 code of that commit:

"c:\Program Files\Git\bin\git.exe" reset --hard 5eb4080
Winston C. Yang