This is usually caused by another repository pushing to the same ref

  1. 新聞資(zī)訊
  2. 技術百科
公司新聞 案例分(fēn)享 技術百科 行業動态

This is usually caused by another repository pushing to the same ref

來源:奇站網絡 浏覽量:4765 發布日期: 2020-06-30

  1. 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à)命令試圖更新遠程倉庫的内容

  1. git pull origin master

報錯refusing to merge unrelated histories(拒絕合并不相關的曆史)

原因

本地倉庫和遠程倉庫實際上是兩個倉庫。
遠程倉庫初始化後自動創建了README.md
本地倉庫是以git init的方式初始化,沒有包含README.md,直接git add . git commit提交本地的文件。

這樣導緻兩邊倉庫的提交不一(yī)樣

解決方法1

  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à)一(yī)篇 spring boot 入門-事務

廈門市中資源網絡服務有限公司

電(diàn)話(huà):13313868605

QQ:3413772931

地址:廈門集美區軟件園三期


                    掃一(yī)掃加我(wǒ)咨詢