0

I made several changes to my local github repository.

I tried to push:

git push --force origin 

but now all changes are lost on my harddisk and the repository has the same look as my remote github, what can I do to get my last version back?

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
ubuseral
  • 427
  • 1
  • 3
  • 14

1 Answers1

1

If you really lost your local repository and nobody else has a copy, then unfortunately there won’t be a way to recover your history. If you just think you have lost it locally but it’s still the same repository, chances are that you can reset to an older HEAD which actually still contains all your commits.

You can find that out by using git reflog. It will show you the changes to the HEAD pointer. If you see a commit that was your old version, you can reset your HEAD to that version by doing git reset --hard HEAD@{n} where n is the number from the reflog.

poke
  • 369,085
  • 72
  • 557
  • 602