GIT Pull deleted my commit

2019-04-11 10:29发布

问题:

After git pull I have done git reset hard to undo the merge with commit id before merge.Somehow my entire commit is gone and I cant the see the commit in history also. But I have the commit id , on git show command I can see my changes.

How can I get back my changes and how to track what mistake I have done

回答1:

if you have the commit hash, and you have not run garbage collection, you can always go back to that commit with git checkout <sha1>. if you want to re-apply it on top of your current head, you could do git cherry-pick <sha1>