遇到問題:
Your branch is ahead of 'origin/master' by 2 commits.
? (use "git push" to publish your local commits)
首先一定要自己手動備份一份代碼 防止意外
這個消息表示你的本地分支比遠程倉庫的 master
分支超前了2個提交。這通常發(fā)生在你在本地進行了一些提交,但還沒有將這些提交推送到遠程倉庫。
我選擇撤回之前的兩次提交(具體次數(shù)根據(jù)實際情況)
首先在git bash中使用git log命令查看最近的提交情況
?我想要恢復到5-7這個版本
所以我使用git reset --hard HEAD~2 回溯到兩次提交之前
?
?此時如圖
再次查看log,發(fā)現(xiàn)已經(jīng)恢復到之前版本文章來源:http://www.zghlxwxcb.cn/news/detail-766974.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-766974.html
到了這里,關于Your branch is ahead of ‘origin/master‘ by 2 commits. (use “git push“ to publish your local commit的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!