Reverse a git reset hard

3

I did some wrong things while doing some testing and deleted all my files both locally and github, how do I revert and not lose everything?

The commands I used and I believe that was what messed up everything were:

git checkout --orphan gh-pages

git reset --hard

git commit --allow-empty -m "Initializing gh-pages branch"

git push origin gh-pages

git checkout master
    
asked by anonymous 29.06.2017 / 03:01

1 answer

5

Tidying up this data starts with git fsck . This command checks the git database to see if everything is okay.

  

Its name is derived from the tools used to check sanity on file systems, File System Consistency checK

We have several options for this git command:

  • --unreachable for objects not reachable in the traditional way
  • --no-reflogs to ignore reflog
  • --full tells git to look in other corners beyond the default

The following command uses these arguments to look for things that are not reachable, ignoring reflog and everything that is corner:

git fsck --unreachable --no-reflogs --full
    
29.06.2017 / 03:27