码云使用git push时报错 error: failed to push some refs to 'git@gitee.com...' 解决办法
生活随笔
收集整理的這篇文章主要介紹了
码云使用git push时报错 error: failed to push some refs to 'git@gitee.com...' 解决办法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
在廖雪峰老師網站學習git教程(git教程地址)時,學到碼云相關內容,發現使用git push origin master命令會報錯,完整的錯誤提示如下
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上還沒有遇到這樣的問題,解決的辦法應該和上面的類似
本文作者:小宇宙55 ? ?原文鏈接:http://www.cnblogs.com/xiaoyuzhou55/p/9517987.html
總結
以上是生活随笔為你收集整理的码云使用git push时报错 error: failed to push some refs to 'git@gitee.com...' 解决办法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 图文详解GitHub的注册与使用
- 下一篇: Markdown如何使用换行