git 無(wú)法push遠(yuǎn)程倉(cāng)庫(kù) Note about fast-forwards 問(wèn)題解決

? git push 遠(yuǎn)程倉(cāng)庫(kù)時(shí),出現(xiàn)以下類似錯(cuò)誤,'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.

錯(cuò)誤:non-fast-forward

遠(yuǎn)程倉(cāng)庫(kù):origin

遠(yuǎn)程分支:master

本地分支:master

完整報(bào)錯(cuò)代碼可能是這樣的:

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

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

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

解決方案:因?yàn)檫h(yuǎn)程倉(cāng)庫(kù)新建時(shí),有LIENCE,由于本地倉(cāng)庫(kù)和遠(yuǎn)程倉(cāng)庫(kù)有不同的開(kāi)始點(diǎn),也就是兩個(gè)倉(cāng)庫(kù)沒(méi)有共同的commit出現(xiàn),無(wú)法提交,此時(shí)我們需要allow-unrelated-histories。也就是我們的 pull 命令改為下面這樣的:

git pull origin master --allow-unrelated-histories

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

git pull --allow-unrelated-histories

然后 git push 就可以了。

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

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

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