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