網(wǎng)站首頁 編程語言 正文
解決辦法:error: failed to push some refs to 'https://github.com/xxxx.git'
作者:Logbook怪 更新時(shí)間: 2022-04-11 編程語言在github遠(yuǎn)程創(chuàng)建倉庫后, 利用gitbash進(jìn)行提交本地文件的時(shí)候出現(xiàn)如下錯(cuò)誤:
[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: 進(jìn)行push前先將遠(yuǎn)程倉庫pull到本地倉庫
$ git pull origin master #git pull --rebase origin master
$ git push -u origin master
2: 強(qiáng)制push本地倉庫到遠(yuǎn)程 (這種情況不會(huì)進(jìn)行merge, 強(qiáng)制push后遠(yuǎn)程文件可能會(huì)丟失 不建議使用此方法)
$ git push -u origin master -f
3: 避開解決沖突, 將本地文件暫時(shí)提交到遠(yuǎn)程新建的分支中
$ git branch [name]
# 創(chuàng)建完branch后, 再進(jìn)行push
$ git push -u origin [name]
我使用的是直接加入?yún)?shù)-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
相關(guān)推薦
- 2022-04-17 python中l(wèi)ambda匿名函數(shù)詳解_python
- 2022-04-10 element input輸入框千分位無法回顯問題解決方法
- 2023-05-13 Python?readline()和readlines()函數(shù)實(shí)現(xiàn)按行讀取文件_python
- 2022-06-06 MybatisPlus二級(jí)緩存體系探究分析_相關(guān)技巧
- 2023-05-20 pytorch中forwod函數(shù)在父類中的調(diào)用方式解讀_python
- 2022-02-09 Linux驅(qū)動(dòng)之platform總線詳解_Linux
- 2023-01-20 Go語言實(shí)現(xiàn)定時(shí)器的原理及使用詳解_Golang
- 2021-12-24 基于PostgreSQL/openGauss?的分布式數(shù)據(jù)庫解決方案_PostgreSQL
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲(chǔ)小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯(cuò)誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實(shí)現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡單動(dòng)態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對(duì)象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊(duì)列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支