git 無法push遠(yuǎn)程倉庫 Note about fast-forwards 問題解決

? git push 遠(yuǎn)程倉庫時,出現(xiàn)以下類似錯誤,'Note about fast-forwards' in 'git push --help' for details.

To https://github.com/SeshinWei/django.git

! [rejected]? ? ? ? master -> master (non-fast-forward)

error: failed to push some refs to 'https://github.com/SeshinWei/django.git'

hint: Updates were rejected because the tip of your current branch is behind

hint: its remote counterpart. Integrate the remote changes (e.g.

hint: 'git pull ...') before pushing again.

hint: See the 'Note about fast-forwards' in 'git push --help' for details.

錯誤:non-fast-forward

遠(yuǎn)程倉庫:origin

遠(yuǎn)程分支:master

本地分支:master

完整報錯代碼可能是這樣的:

Thereisno tracking informationforthe current branch.Please specify which branch you want to mergewith.See git-pull(1)fordetails.? ? git pull If you wish to set tracking informationforthis branch you can do sowith:? ? git branch --set-upstream-to=origin/ master

原因是沒有指定本地master分支和遠(yuǎn)程origin/master的連接,這里根據(jù)提示:

git branch --set-upstream-to=origin/master master

解決方案:因為遠(yuǎn)程倉庫新建時,有LIENCE,由于本地倉庫和遠(yuǎn)程倉庫有不同的開始點,也就是兩個倉庫沒有共同的commit出現(xiàn),無法提交,此時我們需要allow-unrelated-histories。也就是我們的 pull 命令改為下面這樣的:

git pull origin master --allow-unrelated-histories

如果設(shè)置了默認(rèn)分支,可以這樣寫:

git pull --allow-unrelated-histories

然后 git push 就可以了。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Lesson 3: Using GitHub to Collaborate 3.1 Creating a GitH...
    赤樂君閱讀 6,355評論 3 11
  • origin websiteComparing WorkflowsCentralized Workflow Fea...
    伍帆閱讀 576評論 0 0
  • 首先確定電腦安裝了git 輸入git會產(chǎn)生提示: 如果沒有安裝,那么就網(wǎng)上搜索下載完成安裝. 可以使用命令行安裝,...
    元宇宙協(xié)會閱讀 4,545評論 1 9
  • 題目是一本書的書名,一本被名字耽誤的書。這本書我在初中時第一次看見,我的虐文啟蒙書,高中時又被反復(fù)挑出來看...
    Gusubedy閱讀 600評論 0 1
  • 貝多芬降E大調(diào)第三交響曲,標(biāo)題為《英雄交響曲,為紀(jì)念一位偉人而作》。對,我就是伴著這樣的背景音樂,寫出下面的文字的...
    二十五點一刻閱讀 643評論 0 0

友情鏈接更多精彩內(nèi)容