If you actually made commits, and somehow went to a commit that was not actually your latest, then you can use the reflog to get back to where you were. But it sounds more like you added files with git add
and didn't actually git commit
them. In which case, your problem is much harder. Added files will have created objects in your object database which you can find with git fsck
, but restoring them requires a little more work than you would otherwise need. So which situation are you in?
edit:
Once you see the commit you want in the reflog, say for instance HEAD@{3}
, all you have to do is git reset --hard HEAD@{3}