1

I added changes and made a commit locally

git add .
git commit -m "my changes..."

Realised I had made a mistake in my code so undid the commit

git reset --soft HEAD~1

Then I entered this

git checkout HEAD .

instead of this

git reset HEAD .

So I've dropped a clanger and lost my changes :(

Is there any way to get back the code? Undo the checkout? or is it still in the commit somewhere?

UPDATE: Think I might have an answer!

Found this - Can git undo a checkout of unstaged files

Buried in one of the answers was "git reflog" - which I have never heard of.

Then found this - Undoing git reset?.

So currently making a copy of my folder before doing anything else...

Community
  • 1
  • 1
Russell England
  • 9,436
  • 1
  • 27
  • 41

0 Answers0