網站首頁 編程語言 正文
git項目初次push提示error: failed to push some refs to https://gitee.com/xxxx/gittest.git’解決方案
作者:夢想起航007 更新時間: 2022-04-12 編程語言在本地與遠程新建倉庫并關聯后,初次push可能會遇到以下問題
- $ git push -u origin master
- To https://gitee.com/xxxx/gittest.git
- ! [rejected] master -> master (fetch first)
- error: failed to push some refs to 'https://gitee.com/xxxx/gittest.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.
原因是因為遠程倉庫有一些文件而本地沒有,通常是在遠程建立倉庫時有一些初始化文件比如Readme License 等,并且直接pull會提示warning: no common commits
,對于此類問題可以采用兩種解決辦法
1.git push -f 強制將本地文件推送至遠程,這樣會將遠程倉庫的已有的文件清掉
2. git pull origin master –allow-unrelated-histories 使用此命令告訴 git 允許不相關歷史合并 這樣就能把遠程文件拉取回來。執行此命令后會有一個提示,要求說明為何要講兩個不相關的分支合并,輸入信息后保存即可。
拉取完不同的文件之后再執行git push -u origin master
命令即可push成功。
建議使用第二種辦法
- Merge branch 'master' of https://gitee.com/xxxx/gittest.git
- # Please enter a commit message to explain why this merge is necessary,
- # especially if it merges an updated upstream into a topic branch.
- #
- # Lines starting with '#' will be ignored, and an empty message aborts
- # the commit.
- Merge made by the 'recursive' strategy.
- .gitignore | 66 ++++++++++++
- LICENSE | 339 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- README.en.md | 36 +++++++
- README.md | 37 +++++++
- 4 files changed, 478 insertions(+)
- create mode 100644 .gitignore
- create mode 100644 LICENSE
- create mode 100644 README.en.md
- create mode 100644 README.md
原文鏈接:https://blog.csdn.net/qq_41853988/article/details/122933694
相關推薦
- 2022-05-28 C語言實現隨機抽取紙牌程序_C 語言
- 2022-08-03 goFrame的隊列gqueue對比channel使用詳解_Golang
- 2022-06-25 iOS使用NSURLConnection實現斷點續傳下載_IOS
- 2023-04-12 python中list.copy方法用法詳解_python
- 2023-12-14 Excel如何把兩列互換
- 2022-04-28 python導入導出redis數據的實現_python
- 2022-04-09 一起來了解python的if流程控制_python
- 2022-07-18 Kotlin 正確退出 foreach、foreachIndexed 循環函數
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支