push時git報錯 error: failed to push some refs to 'git@gitee.com:git_zn/jianli.git' 解決辦法


完整的錯誤提示如下

To gitee.com:git_zn/jl.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'git@gitee.com:git_zn/jl.git' 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.

根據錯誤提示 用git pull 將遠程倉庫的內容pull下來

無奈pull下來后再push還是報上述錯誤

 

網上查找資料 找到了下面的解決辦法

在當前本地倉庫下用git bash輸入下面命令

git pull gitee master --allow-unrelated-histories

此時會有一個彈窗,提示你修改一個文檔的內容,不用管他,按ESC鍵

再按SHIFT+;  (SHIFT+;用來輸入一個冒號)  再輸入wq保存

:wq

 

接下來git會把遠程倉庫再pull一次

 

看到這個提示表明pull完成

 

再試試用

 

 git push gitee master
  •  注意
    • git push gitee master  gitee是我的遠程倉庫名字已經被我修改了,默認的一般為origin

 

 

出現上面提示表示push到遠程倉庫成功

 


 

 上面的錯誤我只在碼雲上遇到過,在github上還沒有遇到這樣的問題,解決的辦法應該和上面的類似

 


 

 

錯誤解決辦法參考了廖雪峰老師的一篇文章: https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/00150154460073692d151e784de4d718c67ce836f72c7c4000

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM