Recover from losing uncommitted changes by "git reset --hard"


Is there any way to recover uncommitted changes to the working directory from a git reset --hard HEAD?


For previously committed changes (answer from this SO):

$ git reflog show

4b6cf8e (HEAD -> master, origin/master, origin/HEAD) HEAD@{0}: reset: moving to origin/master 295f07d HEAD@{1}: pull: Merge made by the ‘recursive’ strategy. 7c49ec7 HEAD@{2}: commit: restore dependencies to the User model fa57f59 HEAD@{3}: commit: restore dependencies to the Profile model 3431936 HEAD@{4}: commit (amend): restore admin 033f5c0 HEAD@{5}: commit: restore admin ecd2c1d HEAD@{6}: commit: re-enable settings app

assuming you want to get back to 7c49ec7 (restore dependencies to the User model)

$ git reset HEAD@{2}

You got your day back! :)

How do I get the Git commit count?

git clone through ssh