Home > Software engineering >  how to restore uncomiited changes
how to restore uncomiited changes

Time:07-05

I mistakenly made one commit from my secondary GitHub account and then to delete that commit. I ran these two commands one by one:

git reset --hard HEAD~1 
git push -f origin development 

the commit didn't get deleted but some of my uncommitted changes from my project got deleted somehow. I'm not able to see those changes.

Anyone can help me how to get back those changes.

CodePudding user response:

some of my uncommitted changes from my project got deleted somehow.

Not "somehow". You deleted all uncommitted changes. That, in part, is what reset --hard means.

I'm not able to see those changes. Anyone can help me how to get back those changes.

Probably not. Git records commits. Whatever is in a commit (committed) can be retrieved. But uncommitted is, by definition, not in any commit.

CodePudding user response:

run git reflow show and choose the commit you want to go back. run git reset HEAD@{n}. In my case, it reset HEAD@{3}. [enter image description here][3]

enter image description here

  • Related