網站首頁 編程語言 正文
解決辦法:error: failed to push some refs to 'https://github.com/xxxx.git'
作者:Logbook怪 更新時間: 2022-04-11 編程語言在github遠程創建倉庫后, 利用gitbash進行提交本地文件的時候出現如下錯誤:
[root@foundation38 demo]# git push -u origin master
Username for 'https://github.com': xuefeilong
Password for 'https://xuefeilong@github.com':
To https://github.com/xuefeilong/test.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/xuefeilong/test.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
解決辦法:
1: 進行push前先將遠程倉庫pull到本地倉庫
$ git pull origin master #git pull --rebase origin master
$ git push -u origin master
2: 強制push本地倉庫到遠程 (這種情況不會進行merge, 強制push后遠程文件可能會丟失 不建議使用此方法)
$ git push -u origin master -f
3: 避開解決沖突, 將本地文件暫時提交到遠程新建的分支中
$ git branch [name]
# 創建完branch后, 再進行push
$ git push -u origin [name]
我使用的是直接加入參數-f,但是不推薦比較粗暴:
[root@foundation38 demo]# git push -u origin master -f
Username for 'https://github.com': xuefeilong
Password for 'https://xuefeilong@github.com':
Counting objects: 13, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (13/13), 975 bytes | 0 bytes/s, done.
Total 13 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), done.
To https://github.com/xuefeilong/test.git
+ 5c057df...abfded5 master -> master (forced update)
Branch master set up to track remote branch master from origin.
原文鏈接:https://blog.csdn.net/aaaaaab_/article/details/82315116
相關推薦
- 2022-04-23 C語言復雜鏈表的復制實例詳解_C 語言
- 2022-12-26 C++逆向分析移除鏈表元素實現方法詳解_C 語言
- 2022-04-07 C語言的線性表之順序表你了解嗎_C 語言
- 2024-03-20 spring-boot-maven-plugin報紅的解決辦法
- 2022-07-16 TritonObjDet新增要素的方法
- 2022-02-03 ionic錨點操作
- 2022-07-01 Python查詢缺失值的4種方法總結_python
- 2022-08-11 淺析k8s中各組件和kube?apiserver通信時的認證和鑒權問題_云其它
- 最近更新
-
- 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同步修改后的遠程分支