git push origin master
報錯
error: failed to push some refs to ‘’
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., ‘git pull …’) before pushing again.
hint: See the ‘Note about fast-forwards’ in ‘git push —help’ for details.
執行如下(xià)命令試圖更新遠程倉庫的内容
git pull origin master
報錯refusing to merge unrelated histories(拒絕合并不相關的曆史)
原因
本地倉庫和遠程倉庫實際上是兩個倉庫。
遠程倉庫初始化後自動創建了README.md
本地倉庫是以git init的方式初始化,沒有包含README.md,直接git add .
git commit
提交本地的文件。
這樣導緻兩邊倉庫的提交不一(yī)樣
解決方法1
git pull origin master --allow-unrelated-histories
解決方法2
遠程分(fēn)支上存在本地分(fēn)支中(zhōng)不存在的提交,往往是多人協作開(kāi)發過程中(zhōng)遇到的問題,可以先fetch再merge,也就是pull,把遠程分(fēn)支上的提交合并到本地分(fēn)支之後再push。
如果你确定遠程分(fēn)支上那些提交都不需要了,那麽直接git push origin master -f,強行讓本地分(fēn)支覆蓋遠程分(fēn)支。。。
- 版權所有:奇站網絡 轉載請注明出處
- 廈門市中資源網絡服務有限公司,專業提供網站建設,響應式網站建設,小(xiǎo)程序開(kāi)發,系統定制開(kāi)發。
- 軟件開(kāi)發咨詢熱線:吳小(xiǎo)姐 13313868605