Fatal Not possible to fast-forward, aborting
git是一个很好用的版本管理工具,然而,有时候一些冲突还是让人很郁闷的。
遇到过两次merge
报错,是在不同的情形下出现的。
- 本地分支各自
commit
之后,merge
- 本地
master
分支 pull 远程master
分支
下面记录以下两种情况的处理。
情形1:
我在本地仓库的两条分支dev
和 master
同时开发,各自经过2个提交之后,merge
报错:
fatal: Not possible to fast-forward, aborting.
如果git环境是中文的,那么这个错误信息就是这样的:
fatal:无法快进,终止。
问题的原因:
两个分之同时改了同样的地方,造成冲突。
按理,这种冲突也可以直接运行merge
,然后手动解决这些冲突,再commit
就行了。
然而,这次不行。
那就使用另一种合并分支的办法:rebase
,我的目的是将dev
合并到master
,然后删除dev
:
git checkout master
git rebase dev
这时候报以下错误:
First, rewinding head to replay your work on top of it...
Applying: text:I am on master
Using index info to reconstruct a base tree...
M a.txt
Falling back to patching base and 3-way merge...
Auto-merging a.txt
CONFLICT (content): Merge conflict in a.txt
error: Failed to merge in the changes.
Patch failed at 0001 text:I am on master
The copy of the patch that failed is found in: .git/rebase-apply/patchWhen you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".
这时候需要手动去修改冲突的地方:
<<<<<<< HEAD
I am on devI am on my mark.
=======
I am on master
>>>>>>> text:I am on master
然后,根据上面报错的提示信息,continue
When you have resolved this problem, run "git rebase --continue".
git rebase --continue a.txt: needs merge
You must edit all merge conflicts and then
mark them as resolved using git add
根据提示,add
之后,再看下状态:
git add .
git statusrebase in progress; onto 6114f0b
You are currently rebasing branch 'master' on '6114f0b'.(all conflicts fixed: run "git rebase --continue")Changes to be committed:(use "git reset HEAD <file>..." to unstage)modified: a.txt
已经提示冲突都已经解决,可以继续了:
git rebase --continueApplying: text:I am on master
Applying: commit 2nd
Using index info to reconstruct a base tree...
M a.txt
Falling back to patching base and 3-way merge...
Auto-merging a.txt
这时候dev
分支已经完全合并到了master
分支上了:
git statusOn branch master
nothing to commit, working tree clean
情形2:
其实处理方式跟情形1是一样的,只是稍有不同。
git pull origin masterFrom https://gitee.com/leonxtp/xxxxx* branch master -> FETCH_HEAD
fatal: Not possible to fast-forward, aborting.
这时候直接应用rebase
解决:
git pull origin master --rebaseFirst, rewinding head to replay your work on top of it...
Applying: xxxxxx
Using index info to reconstruct a base tree...
M gradle.properties
Falling back to patching base and 3-way merge...
Auto-merging path/of/file...
Auto-merging path/of/file...
Applying: yyyyyyy
...
关于merge
和rebase
的区别,可以参考:这篇文章。
个人总结起来就是:
merge
不影响原来的commit
,并会新增一个合并的commit
。rebase
是将目标分支插入到两个分支的共同祖先与当前分支的最后面(不是最新)之间,并且修改当前分支原来的commit,但不会增加新的commit
。
问题解决参考SOF。
Fatal Not possible to fast-forward, aborting相关推荐
- Git- Fast Forward和no fast forward
Git 很是强大,在体验过rebase的华丽之后,再次发现之前在TFS上遇到的问题一下都有解了.但也印证了Git深入并非易事.这篇就谈下一个容易迷糊的概念:Fast forward. Fast-For ...
- FFmpeg是什么?(Fast Forward Moving Picture Experts Group)(AVFormat、AVCodec、AVFilter、AVDevice、AVUtil)
文章目录 前言 一.FFmpeg的定义 二.FFmpeg的基本组成模块 (1)FFmpeg的封装模块AVFormat (2)FFmpeg的编解码板块AVCodec (3)FFmpeg的滤镜模块AVFi ...
- git merge 的两种模式的区别 --no-ff与fast forward
git merge 将名字为branchName的分支合并到当前分支 有两种模式 git merge <branchName>:fast forward模式,快速合并,看不出做过合并. 不 ...
- Git的Fast Forward和no fast foward合并模式对比
详细版本见个人博客:Git的Fast Forward和no fast foward合并模式对比 通常,合并分支时,如果没有分歧解决,就会直接移动文件指针,这就是Fast forward模式. 举例来说 ...
- Git 的 Fast Forward 和 no fast foward
原文地址 目录 Fast forward 概述 强制禁用 Fast forward 模式的具体方法 Fast Forward 和 no fast foward 合并模式对比 分支策略 小结 Fast ...
- Git – Fast Forward 和 no fast foward
Git 很是强大,在体验过rebase的华丽之后,再次发现之前在TFS上遇到的问题一下都有解了.但也印证了Git深入并非易事.这篇就谈下一个容易迷糊的概念:Fast forward. Fast-For ...
- 解决git pull中 fatal: Not possible to fast-forward, aborting
原文链接 1. 问题场景 最近工作机从Windows换成了Mac, 发现在Mac 机上pull代码时总会出现"fatal: Not possible to fast-forward, abo ...
- Git pull报 fatal: Not possible to fast-forward, aborting的解决办法
1. 问题场景 本人使用公司的开发机Mac, 发现在Mac 机上pull代码时总会出现"fatal: Not possible to fast-forward, aborting" ...
- Git将主合并到功能分支
本文翻译自:Git merge master into feature branch Let's say we have the following situation in Git: 假设我们在Gi ...
- 2018(农历年)封山之作,和我一起嚼烂Git(两万字长文)
本文是『horseshoe·Git专题』系列文章之一,后续会有更多专题推出 GitHub地址(持续更新): https://github.com/veedrin/horseshoe 博客地址(文章排版 ...
最新文章
- MarkdownPad打开文档This view has crashed错误,内容不显示
- 纯CSS3实现宽屏二级下拉菜单
- HDLBits答案(15)_Verilog有限状态机(2)
- stack videos in ffmpeg
- 开课吧学python靠谱吗-学设计?学Python?看看我的人生是如何开挂!!!
- mysql中log_mysql中log
- SpringBoot SSM 心理咨询论坛社区
- 什么叫预判_挖机事故发生之前,挖机司机做了什么?
- wireless-tools源码分析-iwlist
- 华为设备为(USG6000)的防火墙:配置远程管理防火墙最常见的几种方式。
- IE Tab Plus 安装设置说明
- 超级记忆/图像数字记忆 110位数字图像转换表 81-90
- cocos creator制作微信小游戏
- 多种代码生成炫酷代码雨(推荐)
- bios error 装系统acpi_WIN10重装系统提示错误ACPI?处理重装系统bios acpi错误
- 桂林瑶大叔名老中医馆
- python画画bup_用Python编写一个简单的FUSE文件系统的教程
- 【算法学习笔记】64. 枚举法 SJTU OJ 1381 畅畅的牙签
- SGU 507 Treediff (dsu on tree)
- 火力全开的网易云,会不会给云计算市场增加新的变数?