Git error recovery

Quite unexpectedly for GIT and need a little help.

Hosting my content on Github. Last night, I realized that I hadn’t brought my content to Github for a while, so I opened the github mac client and committed / synchronized in my project. He said that I am 2 commits ahead of the lead branch. I was confused ...

First mistake - So I made a "GIT reset --hard origin / master", then I synchronized it with Github.

I open my laptop the next morning, then open netbeans, and all my work that I have done is gone. I'm in a panic ...

So, I will split up and find this page that describes how to cancel a GIT Reset. I did a great job with this and reset with the previous commit. Here is my git relog:

ce8d01b HEAD@ {0}: reset: moving to HEAD@ {1} fcc0db9 HEAD@ {1}: commit: front page ce8d01b HEAD@ {2}: reset: moving to origin/master a6bda3a HEAD@ {3}: commit: front page cde0712 HEAD@ {4}: commit: Fixed Front Page Slider ce8d01b HEAD@ {5}: commit: Fixed Company Scrolling. dd7b163 HEAD@ {6}: commit: Work on company product and home page 4cc4274 HEAD@ {7}: commit: Added Company Page 1ebed75 HEAD@ {8}: commit (initial): initial 

After I did GIT reset HEAD @ {1}, I opened netbeans and there was still no code, so I thought I might have been wrong. So I did it again, but this time went to HEAD @ {2}. That's where I am now.

 a6bda3a HEAD@ {0}: reset: moving to HEAD@ {3} ce8d01b HEAD@ {1}: reset: moving to HEAD@ {1} fcc0db9 HEAD@ {2}: commit: front page ce8d01b HEAD@ {3}: reset: moving to origin/master a6bda3a HEAD@ {4}: commit: front page cde0712 HEAD@ {5}: commit: Fixed Front Page Slider ce8d01b HEAD@ {6}: commit: Fixed Company Scrolling. dd7b163 HEAD@ {7}: commit: Work on company product and home page 4cc4274 HEAD@ {8}: commit: Added Company Page 1ebed75 HEAD@ {9}: commit (initial): initial 

But I still do not see my code. Is there anything else I need to do?

thanks for the help

+4
source share
1 answer

From your reflog,

  git reset --hard a6bda3a 

should restore your content as it was before your git reset --hard origin/master .

Then, if the GitHub branch is ahead , I would recommend:

 git pull --rebase # check everything is still working # git add and git commit if needed git push 
+2
source

All Articles