Updates were rejected because the tip of your current branch is behind hint: its remote counterpart
在使用git管理代码仓库的时候,有时在使用git push origin common_branch:common_branch提交代码的使用出现如下问题:
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.
使用git pull origin common_branch出现:
* branch master -> FETCH_HEADerror: Your local changes to the following files would be overwritten by merge:README.md
Please commit your changes or stash them before you merge.
Aborting
提示说当前本地的分支落后于远程分支,远程分支有变化。自己开发,也没有改动,怎么会有变化?使用git pull出现下面的提示:
error: Your local changes to the following files would be overwritten by merge:README.md
Please commit your changes or stash them before you merge.
Aborting
使用git pull origin common_branch有出现如下提示:
* branch common_branch -> FETCH_HEADREADME.md
Please commit your changes or stash them before you merge.
Aborting
综上提示,找到远程仓库,发现同事修改了README.md文件,跟自己的README.md冲突,可是使用使用git pull 有拉不下来远程分支,无法合并解决分支冲突。
遇到这种情况,应该怎么解决呢?看网上好多说先用 pull -f origin common_branch命令,强制将远程代码拉倒本地,可是问题还是存在。甚至有人说使用git push -f origin master强制push到远端,可是这样会覆盖远端修改,在不知道远程修改情况的情况下,很容易出问题,所以不推荐。
上面两种方案都无法解决的情况下,又应该怎么操作呢?可以参见以下解决过程:
git branch -m feature/commmon // 首先将有冲突的本地分支改名
git add . // 添加所有修改
git commit -m "update README.md and add task interface" // 提交修改内容
git push origin feature/common:feature/common // 将本地分支推送到远端git fetch common_branch:common_branch // 重新拉取远程公共分支到本地
git checkout common_branch // 切到公共分支
git merge feature/common // 将本地修改的feature/common分支内容合并到公共分支common_branch// 之后,修改冲突的代码,运行golangci-lint run检查代码通过后,重新提交代码
git add .
git commit -m "update README.md and add task interface and fix conflict"
git push origin common_branch:common_branch
其中,在git merge feature/common过程中,出现如下提示:
Auto-merging README.md
CONFLICT (content): Merge conflict in README.md
Automatic merge failed; fix conflicts and then commit the result.
上面的common_branch代指公共分支,feature/common代指开发迭代的功能分支。
参考
hint: Updates were rejected because the tip of your current branch is behind hint: its remote counte
Updates were rejected because the tip of your current branch is behind hint: its remote counterpart相关推荐
- Git工作笔记004---torisegit使用时Updates were rejected because the tip of your current branch i
JAVA技术交流QQ群:170933152 因为要跟别的公司一块合作开发,我们用svn他们用git,现在又得用git 我在提交的时候:报如下错误: git.exe push --progress &q ...
- Git提交失败之 Updates were rejected because the tip of your current branch is behind
错误显示 D:\devworkspace\ecpphoton\jcodef>git push To https://github.com/osxm/jcodef.git! [rejected] ...
- github上的版本和本地版本冲突的解决方法(Updates were rejected because the tip of your current branch is behind)
github上的版本和本地版本冲突的解决方法(Updates were rejected because the tip of your current branch is behind) 参考文章: ...
- Updates were rejected because the tip of your current branch is behind
项目场景: 今天学习torch的第二天 谁知我在git push -u origin master的时候报错了 问题描述 Updates were rejected because the tip o ...
- hint: Updates were rejected because the tip of your current branch is behind(git push线上与本地版本冲突问题)
Git本地代码推送到线上出现的问题 错误信息为: error: failed to push some refs to 'http://**:**/**/**.git' hint: Updates w ...
- 成功解决:Updates were rejected because the tip of your current branch is behind its remote...【解决方法】
一.报错发生 最近使用git,一直使用命令行操作.昨天突发奇想研究了一番git的GUI,结果由于操作不当产生了如下报错: Updates were rejected because the tip o ...
- git提交时报错:Updates were rejected because the tip of your current branch is behind
遇到这个问题别慌,这个说明你当前的分支代码不是最新的代码,你需要去更新一下master分支 push前先将远程repository修改pull下来 git checkout mastergit pul ...
- 在git上传报错Updates were rejected because the tip of your curren branch is behind its remote counterpart
个人认为,这个报错的原因是因为远程repository和本地的repository有冲突造成的 错误翻译 提示:由于当前分支的尖端位于其远程对应的后面,因此更新被拒绝. 合并远程更改(例如'git p ...
- error: failed to push some refs to ‘xx.git‘ hint: Updates were rejected because the tip of your curr
被fork的项目B<-你fork项目B产生的项目A<-别人fork你的项目B产生的项目C 作为中间人,需要保持你fork的项目最新的同时,还需要保持你本地的项目与你产生的远程项目同步 对( ...
- 从git提交出现“updates were rejected because a pushed branch tip is behind its remote”到提交成功解决问题的过程
git提交代码从reject到提交成功全过程 1. 问题重述 2. 解决过程 出现新问题:Your local changes to the following files would be over ...
最新文章
- linux shell 脚本实现tcp/upd协议通讯(重定向应用)
- Cisco学习笔记 CCNP-EIGRP
- Java后端学习路线【哔哩哔哩网站】【Java基础、SSM框架、Maven、Mysql、Idea的使用、Springboot、Sprinfcloud、设计模式】
- Android Service的思考(4)
- PostgreSQL 10.1 手册_部分 I. 教程_第 2 章 SQL语言
- Mybatis实现CRUD操作
- 大顶堆删除最大值_C++|使用STL算法创建、调整、输出最大堆、最小堆
- 文本的数据导入到数据库中 mysql
- sql并行度_SQL Server最大并行度的重要性
- V 神呼吁宽大处理,以太坊开发者 Virgil Griffith 被判入狱 63 个月
- java中int边界值_数组中重复的数字2019.12.06
- 工厂模式 接口 封装 实例
- 这一年,这些书:2020年读书笔记
- 不同SIP客户端使用说明
- 33暴力破解(MD5撞击)
- 联合几位大佬给大家送110本技术书籍!包邮到家!!
- Window10 和 Ubuntu20.04 双系统安装
- 《唐诗三百首》中的童年记录
- Teranex AV标准转换器
- 第十四届蓝桥杯模拟赛c++ 试题 I
热门文章
- html5播放器声音小,页面声音播放(HTML5 embed标签)
- RL(Chapter 5): Monte Carlo Methods (MC) (蒙特卡洛方法)
- xposed框架报错安装不上解决办法
- 唐门暗器之私有云排名
- stm32呼吸灯c语言程序,STM32之呼吸灯
- python 网络编程模块_详细介绍Python网络编程模块
- postgresql数据库 timescaledb 时序库 超级表 块的压缩(compress_chunk()的应用)
- 安卓设备设置 orientation 最简单的方法
- Dicom标签之(0020,0037) Image Orientation (Patient)
- [02.20][中国][人再囧途之泰囧][HD-RMVB.720p.国语中字][2012年喜剧]