3

Mistakenly, i hard reset my git repository. By doing this all the changes that i have made has been gone. Now, i want to rollback Git to all the uncommitted changes. Please help me with this.

Ravi Kumar
  • 432
  • 4
  • 14
  • Uncommited changes have never been in Git, you can't "rollback" to them, so your problem really is how to recover deleted files. See http://superuser.com/questions/671773/how-to-recover-deleted-files-on-windows – sashoalm Mar 18 '14 at 06:16
  • @sashoalm I am using amazon ec2, do you know how can i recover that files... – Ravi Kumar Mar 18 '14 at 06:27
  • Were your changes staged but uncommitted, or were they unstaged, as well? – sashoalm Mar 18 '14 at 09:45

1 Answers1

1

"uncommitted changes" means local repo (even though you have a remote repo on amazon ec2)

That means you must have added (git add) files to a local clone, then do a git reset --hard.

If that is the case, you can still find those added files with a git fsck, as described in Recover files that were added to the index but then removed by a git reset:

  • first, do a full backup of your current repo
  • then try a git fsck --full --unreachable --no-reflog
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • @janos please see the screenshot, when i used the above command. http://i.imgur.com/oz5ItHX.png – Ravi Kumar Mar 18 '14 at 07:27
  • @RaviKumar your picture looks fine. As mentioned in the answer I linked (http://stackoverflow.com/a/10783950/6309), you need to do a `git cat-file -p ` with various SHA1 listed in your picture, in order to see if your recognize the *content* of the files you have lost after the `git reset`. – VonC Mar 18 '14 at 07:59