[GIT]解决:failed to push some refs to ...(过程重现)
本问题有很多种情况,解决方法也很多,本文只针对笔者本人的自身诉求和情况,选择了一种适合我的解决方法。仅供参考。
1 问题描述
johnnyzen@XXDSSS MINGW64 /e/source_code/BigData/bdp_common_data_service (develop)
$ git push
To gitlab-bigdata.johnnyzen.cn:platform-software/bigdata/bdp_common_data_service.git
! [rejected] develop -> develop (non-fast-forward)
error: failed to push some refs to 'gitlab-bigdata.johnnyzen.cn:platform-software/bigdata/bdp_common_data_service.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
2 问题分析
笔者即小伙伴B
- Step0 小伙伴A、B:同步【远程仓库】的代码至【本地仓库】
git pull
- Step1.1 小伙伴A:修改【本地】的代码,并提交至【本地仓库】,再推送至【远程仓库】
修改本地代码
git add *
git pull
git commit -m "xxxx"
git push
- Step1.2 小伙伴B:修改【本地】的代码,并提交至【本地仓库】,但未推送至【远程仓库】
修改本地代码
git add *
git commit -m "xxxxx"
- Step2 小伙伴B:再次修改/新增/删除了【本地】的代码,并尝试推送先前提交的【本地仓库】代码至【远程仓库】
再次修改/新增/删除了【本地】的代码
git push
(此时,出现了本错误)
To gitlab-bigdata.johnnyzen.cn:platform-software/bigdata/bdp_common_data_service.git
! [rejected] develop -> develop (non-fast-forward)
error: failed to push some refs to 'gitlab-bigdata.johnnyzen.cn:platform-software/bigdata/bdp_common_data_service.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
3 解决方法
此问题有很多解决方法,答主仅提供了一种我个人的解决方式
3.1 解决方法
- Step3 检查哪些代码是Step2过程中修改的代码
那么这个时候,小伙伴B可以先
git pull尝试同步一下远程仓库的代码,以检测是哪些文件出现了冲突。
git pull


Step4 将上述变更文件拷贝到源码工程外,并使得Step2过程无任何变更
Step5 同步远程仓库的代码,并在本地解决可能出现的冲突
git pull
[并解决可能出现的冲突]

- Step6 推送代码至【远程仓库】
git push

- Step7 还原Step4中备份的变更代码至源码工程内
3.2 其他解决思路
- 解决思路2
备份小伙伴B的2次变更文件,重置本地仓库的代码至Step0的状态,然后还原先前备份的变更文件后,再重新提交、推送至远程仓库
- ...
X 参考文献
[GIT]解决:failed to push some refs to ...(过程重现)的更多相关文章
- git解决"failed to push some refs to"问题
当我们正常的使用git发布文件更新Github仓库时, 比如我想传一张照片上去,首先把照片"2.png"复制到了".git"文件夹追踪的本地仓库中: 在Git ...
- 解决failed to push some refs to git
Administrator@PC-20150110FGWU /K/cocos2d/yc (master) $ git push -u origin master To git@github.com:y ...
- 如何解决failed to push some refs to git
$ git push -u origin master To git@github.com:yangchao0718/cocos2d.git ! [rejected] master -& ...
- [转载]如何解决failed to push some refs to git
Administrator@PC-20150110FGWU /K/cocos2d/yc (master) $ git push -u origin master To git@github.com:y ...
- GitHub上传项目时——解决failed to push some refs to git
原文地址:https://jingyan.baidu.com/article/f3e34a12a25bc8f5ea65354a.html 遇到的问题: error: failed to push so ...
- git中failed to push some refs to git问题解决及基本使用
国庆归来准备试用一下git,在提交代码时遇到时遇到一些问题 提交时使用git push origin master 出现failed to push some refs to git 回想一下,创建该 ...
- 【转载】如何解决failed to push some refs to git
在使用git 对源代码进行push到gitHub时可能会出错,信息如下 此时很多人会尝试下面的命令把当前分支代码上传到master分支上. $ git push -u origin master ...
- 解决failed to push some refs to
由于github我使用了dev和feature分支,团队合作合并到dev,个人开发都是feature....今天在本地feature中git pull origin dev 出现 在使用git 对源代 ...
- 解决failed to push some refs to 'git@github.com:TQBX/GIT-Github-.git'问题
解决以下问题问题: git pull origin master --allow-unrelated-histories 进入vim界面->ESC->:wq 重复第一步->git p ...
- 解决 failed to push some refs to 'git@github.com:zle1992/head-first-java' hint: Updates were rejected because the tip of your curr
问题描述: 寒假之前用实验室电脑push到github 上head first java 的程序,寒假回家后,想用自己的笔记本继续编,继续push . 我先从github下载zip到本地,然后 解压后 ...
随机推荐
- Ubuntu Server搭建个人服务器
Ubuntu Server20.04.5 LTS [参考资料] Ubuntu官方地址:https://www.ubuntu.com/ Ubuntu论坛地址:https://ubuntuforums.o ...
- css盒子水平垂直居中的几种方式
第一种:son盒子中定位的上下左右全部为0,然后margin:auto 1 <!DOCTYPE html> 2 <html lang="en"> 3 < ...
- 2023 年十大 API 管理趋势
本文探讨了 API 管理在数字化转型中的重要性,以及 API 管理面临的挑战和发展机遇.文章重点介绍了十大 API 管理发展趋势,包括 API 安全性.API 标准化.云端 API 管理解决方案.低代 ...
- P1350 车的放置 题解
一.题目描述: 给你一个网格棋盘,a,b,c,d 表示了对应边长度,也就是对应格子数. 例如,当 a=b=c=d=2 时,对应了下面这样一个棋盘: 想要在这个棋盘上放 k 棋子,也就是这 k 个棋子没 ...
- cf1774f解题报告
Magician and Pigs 分析一下三个操作分别干了些什么 新添一只猪 使血量为 \(x\) 的猪血量变为 \(\max(x-v,0)\) 设前面操作后猪总共会受到 \(s\) 的伤害,复制一 ...
- 响应式的 switchboard:让又大又慢的Vue/AIpine 页面爆快
我的提示: AIpine 是一个js 库,官网口号是 "一个新的轻量极javascript框架",其实我之前也没接触过,翻译这篇文章时才注意到 官方地址: [AIpine.js]h ...
- 推荐Visual Studio四款好用插件
我要推荐的4个插件,合理使用可以提高工作效率,分别是: 1.Markdown Editor 可以在vs预览markdown文件的插件 2.Add New File 我们原本在vs中新建文件,需要添加新 ...
- Prism Sample 2
例2引入了Region的概念. 例1中我们提到bootstrapper与app.xaml.cs,现在是这样的: public partial class App : PrismApplication ...
- C#自行实现安装卸载程序(不使用官方组件)
正规软件建议还是使用官方的标准安装程序组件,因为官方的标准安装/卸载组件能更好的与操作系统衔接,安装和卸载流程更加规范. 今天提供一种野路子,全用代码实现安装卸载器. 需要写一个程序,包含安装器.卸载 ...
- CTFShow 反序列化 Web 255-266
CTFShow 反序列化 255-266 漏洞原理 未队用户输入的序列化字符串进行检测,导致攻击者可以控制反序列化过程,从而导致代码执行,SQL注入,目录遍历等后果. 触发条件 unserialize ...