本问题有很多种情况,解决方法也很多,本文只针对笔者本人的自身诉求和情况,选择了一种适合我的解决方法。仅供参考。

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 ...(过程重现)的更多相关文章

  1. git解决"failed to push some refs to"问题

    当我们正常的使用git发布文件更新Github仓库时, 比如我想传一张照片上去,首先把照片"2.png"复制到了".git"文件夹追踪的本地仓库中: 在Git ...

  2. 解决failed to push some refs to git

    Administrator@PC-20150110FGWU /K/cocos2d/yc (master) $ git push -u origin master To git@github.com:y ...

  3. 如何解决failed to push some refs to git

    $ git push -u origin master To git@github.com:yangchao0718/cocos2d.git ! [rejected]        master -& ...

  4. [转载]如何解决failed to push some refs to git

    Administrator@PC-20150110FGWU /K/cocos2d/yc (master) $ git push -u origin master To git@github.com:y ...

  5. GitHub上传项目时——解决failed to push some refs to git

    原文地址:https://jingyan.baidu.com/article/f3e34a12a25bc8f5ea65354a.html 遇到的问题: error: failed to push so ...

  6. git中failed to push some refs to git问题解决及基本使用

    国庆归来准备试用一下git,在提交代码时遇到时遇到一些问题 提交时使用git push origin master 出现failed to push some refs to git 回想一下,创建该 ...

  7. 【转载】如何解决failed to push some refs to git

    在使用git 对源代码进行push到gitHub时可能会出错,信息如下   此时很多人会尝试下面的命令把当前分支代码上传到master分支上. $ git push -u origin master ...

  8. 解决failed to push some refs to

    由于github我使用了dev和feature分支,团队合作合并到dev,个人开发都是feature....今天在本地feature中git pull origin dev 出现 在使用git 对源代 ...

  9. 解决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 ...

  10. 解决 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到本地,然后 解压后 ...

随机推荐

  1. SMT贴片加工钢网工艺制作方法

    smt贴片加工过程中,首先要进行锡膏印刷,而锡膏印刷的工作原理就是用机器刮刀将锡膏推送到钢网的孔洞中,使锡膏与pcb板的电子元器件接触,为下一步焊接做准备.钢网的作用就是与pcb板焊盘位置固定,使锡膏 ...

  2. 中国省市区--地区SQL表

    SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for rc_district -- ---- ...

  3. 分享一个开源的windows安卓投屏工具,scrcpy

    看到scrcpy可能很多人会以为是大名鼎鼎的Scrcpy(一个十分强大的多线路爬虫框架),sorry今天分享的主角不是他,而是他: github地址:https://github.com/Genymo ...

  4. 云原生2.0网关API标准发展趋势

    摘要:Gateway API希望取代Ingress API. 本文分享自华为云社区<云原生2.0网关API标准发展趋势>,作者:华为云云原生团队 . 云原生网关API标准背景及发展现状 G ...

  5. SpringBoot自定义cron表达式注册定时任务

    springBoot自定义cron表达式注册定时任务 一.原理 1.使用Spring自带的TaskScheduler注册任务 2.注册后返回:ScheduledFuture,用于取消定时任务 3.注册 ...

  6. 苹果怎么查看UDID iPhone/iPad查看UDID教程【详解】

      在开发iPhone和iPad软件的时候,要使用UDID来做真机测试,那么如何查看iPhone或者iPad的UDID呢?下面介绍三种最简单的查看UDID的方法,供大家参考!下面就详情来看看. 1.使 ...

  7. 深入理解python虚拟机:调试器实现原理与源码分析

    深入理解python虚拟机:调试器实现原理与源码分析 调试器是一个编程语言非常重要的部分,调试器是一种用于诊断和修复代码错误(或称为 bug)的工具,它允许开发者在程序执行时逐步查看和分析代码的状态和 ...

  8. 【问题排查篇】一次业务问题对 ES 的 cardinality 原理探究

    作者:京东科技 王长春 业务问题 小编工作中负责业务的一个服务端系统,使用了 Elasticsearch 服务做数据存储,业务运营人员反馈,用户在使用该产品时发现,用户后台统计的订单笔数和导出的订单笔 ...

  9. Prism Sample 7 Modules Directory

    这种方式用扫描目录的方式来增加模块,具备最大的灵活性 仍然在App.xaml.cs中增加了以下代码 protected override IModuleCatalog CreateModuleCata ...

  10. 2021-10-03:合并两个有序数组。非递减数组nums1和nums2。合并这两个数组并放在nums1中。力扣88。

    2021-10-03:合并两个有序数组.非递减数组nums1和nums2.合并这两个数组并放在nums1中.力扣88. 福大大 答案2021-10-03: 从右往左遍历nums1和nums2,谁大拷贝 ...