? 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 就可以了。