GIT相当新,需要一些帮助.
在Github上托管我的内容.昨晚我意识到我没有把我的内容推到Github一段时间,所以我打开了github mac客户端并对我的项目进行了提交/同步.它说我在主分支之前是2次提交.我很困惑…
第一个错误 –
所以我做了一个“git reset –hard origin / master”,然后我和Github同步了.
第二天早上我打开笔记本电脑,然后打开netbeans,我做的所有工作都没了.我处于恐慌模式……
所以我在谷歌上搜索this page,它描述了如何撤消GIT重置.我很好地遵循了这一点并重置为之前的提交.
这是我的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
在我做了git reset HEAD @ {1}之后我打开了netbeans并且代码仍然不在那里所以我想也许我做错了.所以我又做了一次,但这次是去了HEAD @ {2}.这就是我现在的位置.
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
但我还是看不到我的代码.我还需要做些什么吗?
谢谢您的帮助
最佳答案 从您的reflog,a
git reset --hard a6bda3a
应该恢复你的git重置之前的内容–hard origin / master.
那么,如果GitHub branch is ahead,我会推荐一个:
git pull --rebase
# check everything is still working
# git add and git commit if needed
git push