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

完整的錯誤提示以下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下來github

無奈pull下來後再push仍是報上述錯誤bash

 

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

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

git pull gitee master --allow-unrelated-histories

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

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

:wq

 

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

 

看到這個提示代表pull完成文檔

 

再試試用it

 

 git push gitee master
  •  注意
    • git push gitee master  gitee是個人遠程倉庫名字已經被我修改了,默認的通常爲origin

 

 

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

 


 

 上面的錯誤我只在碼雲上遇到過,在github上尚未遇到這樣的問題,解決的辦法應該和上面的相似

 


 

 

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

相關文章
相關標籤/搜索