? git push 遠程倉庫時,出現(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
遠程倉庫:origin
遠程分支: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分支和遠程origin/master的連接沃暗,這里根據(jù)提示:
git branch --set-upstream-to=origin/master master
解決方案:因為遠程倉庫新建時冤馏,有LIENCE典徊,由于本地倉庫和遠程倉庫有不同的開始點,也就是兩個倉庫沒有共同的commit出現(xiàn)顾瞻,無法提交泼疑,此時我們需要allow-unrelated-histories。也就是我們的 pull 命令改為下面這樣的:
git pull origin master --allow-unrelated-histories
如果設(shè)置了默認分支荷荤,可以這樣寫:
git pull --allow-unrelated-histories
然后 git push 就可以了退渗。