How to undo git reset --soft to get my changes back?

dennis picture dennis · Jan 10, 2014 · Viewed 23.6k times · Source

I had some local changes in my directory that I committed using git commit. Later I realized that by mistake my changes broke my build. So I did a "git reset --soft" on my repo. But I am screwed up, as I did not back up the changes that were all undone, as some of them did contain the new functionality that I wanted. Any help on how to undo a "git reset --soft" operation so that I can get my committed changes back.

Answer

Franck picture Franck · Jan 10, 2014

In $ git reflog you should find some of your commits. Once you find the latest commit that you want to move to

you should reset back to your commit id $ git reset _Your_Hash_ , as $ git reset --soft just reset the files and not the index or working tree.