Git recover uncommitted changes

Viewed 23275

I had a lot of local changes.

I just accidentally did

git merge another_branch
git reset --hard HEAD^

on a lot of work. :( with the intention I didn't want the merged changes in here.

How do I recover the original state?

No, the local changes were never committed/stashed.

No way?

6 Answers

Try undoing on the file directly from the IDE. You'll get what you need.

It is probably not helpful for @Lakshman Prasad, but it will help someone else :-D

Look into the Recycle Bin!

I found my deleted (uncommitted) files there.

I was able to recover my files, by using git log -g. My changes were there, because I committed them once, uncommitted my changes and then I saw all files on which I was working were lost.

By doing git log -g || git reflog -g it will display the recent commit logs.

I found my commit hash and I checked it out to that using this command: git reset #commitHashID

This may help someone with a similar scenario.

Related