Reputation: 1203
Fairly new to GIT and need a little help.
Hosting my content on Github. Last night I realized I hadn't pushed my content up to Github in awhile so I opened up the github mac client and did a commit/sync on my project. It said I was 2 commits ahead of the master branch. I was confused...
1st Mistake - So I did a " git reset --hard origin/master", I then synced up with Github.
I open up my laptop the next morning, then open up netbeans and all my work that I did is gone. I'm in panic mode...
So I'm Googling around and find this page which describes how to undo a GIT Reset. I followed that pretty well and reset to 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 the code still wasn't there so I thought maybe I did the wrong one. So I did it again but this time went to HEAD@{2}. Which is 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 can't see my code. Is there something else I need to do?
Thanks for the help
Upvotes: 4
Views: 630
Reputation: 1323753
From your reflog, a
git reset --hard a6bda3a
should restore your content as it was before your git reset --hard origin/master
.
Then, if GitHub branch is ahead, I would recommend a:
git pull --rebase
# check everything is still working
# git add and git commit if needed
git push
Upvotes: 2