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

  1. 新聞資訊
  2. 技術百科
行業動态 公司新聞 案例分享 技術百科

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

來(Come)源:奇站網絡 浏覽量:5218 發布日期: 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.

執行如下命令試圖更新遠程倉庫的(of)内容

  1. git pull origin master

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

原因

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

這(this)樣導緻兩邊倉庫的(of)提交不(No)一(one)樣

解決方法1

  1. git pull origin master --allow-unrelated-histories

解決方法2

遠程分支上存在(exist)本地(land)分支中不(No)存在(exist)的(of)提交,往往是(yes)多人(people)協作(do)開發過程中遇到(arrive)的(of)問題,可以(by)先fetch再merge,也就是(yes)pull,把遠程分支上的(of)提交合并到(arrive)本地(land)分支之後再push。

如果你确定遠程分支上那些提交都不(No)需要(want)了(Got it),那麽直接git push origin master -f,強行讓本地(land)分支覆蓋遠程分支。。。

标簽:
下一(one)篇 spring boot 入門-事務

廈門極極網絡科技有限公司

電話:13313868605

QQ:3413772931

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


                    掃一(one)掃加我(I)咨詢