git rebase冲突说明(base\remote\local概念说明)

主线日志及修改

bash 复制代码
$ git log master -p
commit 31213fad6150b9899c7e6b27b245aaa69d2fdcff (master)
Author: 
Date:   Tue Nov 28 10:19:53 2023 +0800

    4

diff --git a/123.txt b/123.txt
index 294d779..a712711 100644
--- a/123.txt
+++ b/123.txt
@@ -1,3 +1,4 @@
 1
 2
 3
+4^M

commit a77b518156879a5d7e93636eb826d40f873ff919
Author:
Date:   Tue Nov 28 10:19:37 2023 +0800

    3

diff --git a/123.txt b/123.txt
index bd956ea..294d779 100644
--- a/123.txt
+++ b/123.txt
@@ -1,2 +1,3 @@
 1
 2
+3^M

commit 9cb0b0d6c2c638fa9c35685972d0b57edbfd2d95
Author: 
Date:   Tue Nov 28 10:19:30 2023 +0800

    2

diff --git a/123.txt b/123.txt
index f33dfa2..bd956ea 100644
--- a/123.txt
+++ b/123.txt
@@ -1 +1,2 @@
 1
+2^M

commit 137b1d78d1f696c5dc21d595142e0681bb041e1a
Author:
Date:   Tue Nov 28 10:19:00 2023 +0800

    1

diff --git a/123.txt b/123.txt
new file mode 100644
index 0000000..f33dfa2
--- /dev/null
+++ b/123.txt
@@ -0,0 +1 @@
+1^M

冲突分支日志及修改(其中第2、3次提交为冲突提交,第四次为相同提交)

bash 复制代码
$ git log master-1 -p
commit 53d255eb15f59d0395453c7688a038bb9cf05816 (HEAD -> master-1)
Author: 
Date:   Tue Nov 28 10:21:20 2023 +0800

    4

diff --git a/123.txt b/123.txt
index 6065780..403b9a5 100644
--- a/123.txt
+++ b/123.txt
@@ -1,3 +1,4 @@
 1
 1-2
 1-3
+4
\ No newline at end of file

commit 7ac2b8868b83c4c1a50b52a3808c7df870ad90bb
Author: 
Date:   Tue Nov 28 10:21:10 2023 +0800

    1-3

diff --git a/123.txt b/123.txt
index ea907e6..6065780 100644
--- a/123.txt
+++ b/123.txt
@@ -1,2 +1,3 @@
 1
 1-2
+1-3^M

commit 91cf797a56db8a42623e707e01435d6d82f19402
Author: 
Date:   Tue Nov 28 10:21:02 2023 +0800

    1-2

diff --git a/123.txt b/123.txt
index f33dfa2..ea907e6 100644
--- a/123.txt
+++ b/123.txt
@@ -1 +1,2 @@
 1
+1-2^M

commit 137b1d78d1f696c5dc21d595142e0681bb041e1a
Author: 
Date:   Tue Nov 28 10:19:00 2023 +0800

    1

diff --git a/123.txt b/123.txt
new file mode 100644
index 0000000..f33dfa2
--- /dev/null
+++ b/123.txt
@@ -0,0 +1 @@
+1^M

在master-1分支中运行git rebase,结果如下:

bash 复制代码
$ git rebase master
Auto-merging 123.txt
CONFLICT (content): Merge conflict in 123.txt
error: could not apply 91cf797... 1-2
hint: Resolve all conflicts manually, mark them as resolved with
hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
hint: You can instead skip this commit: run "git rebase --skip".
hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
Could not apply 91cf797... 1-2

一、冲突部分全部手动解决不跳过,并以master-1为准

base 为 master-1 冲突提交(1-2)之前和 master 不冲突的BASE公共部分

local为 master 目的分支最新提交的全部内容

remote 为当前 master-1 冲突待(remote 在词典中可以翻译为相差很大的)提交的内容

提交1-2冲突后,解决1-3冲突显示如下:

base 和 remote的概念理解保持一致,但local与预期不符.

local更新为:当前 master-1 已经提交并保存的了部分,也就是最终master-1的在硬盘内(local)的内容

提交冲突1-3后,继续:

最终rebase完成。

二、第2个冲突以master为准,其他以master-1为准

解决1-2冲突,修改文件如下后再提交:

解决1-3冲突,修改文件如下后再提交。

前面说 base 为 master-1 冲突提交(1-2)之前和 master 不冲突的BASE公共部分,但这里与预期不符,修改为:

base 为 master-1 冲突提交之前和 master 不冲突的提交,也就是可以共用(BASE)的提交,且为未修改前的提交

区别在于主体从内容,变成了一次提交,且为未修改前的提交

当前冲突修改界面说明:

这里local为上次解决冲突后的结果,也就是master-1(新),base变成冲突的上个提交1-2的冲突部分master-1(原始).

原始master-1日志列表 : 1-2 > 1-3 > 4

解决冲突1-2后 master-1 日志列表: (LOACL):1-2(新)> 1-3 >4 他们的共用BASE 提交 就是1-2(未修改前)

解决1-4冲突:

当前冲突修改界面说明:

原始master-1日志列表 : 1-2 > 1-3 > 4

解决冲突1-2后 master-1 日志列表: (LOACL):1-2(新)> 1-3(新) >4

三、第2冲突跳过,其他以master-1为准

1-2跳过,解决1-3冲突界面如下:

界面说明:

当前解决1-3,本地LOCAL 由于跳过1-2,所以LOCAL内容还是原始的1234. 这里相当于1-3 和 master (1-2跳过了形但魂还在) 进行rebase , 所以BASE为冲突分支的1-2。

总结:
base为 master-1 冲突提交之前和 master 不冲突的提交,也就是可以共用(BASE)的提交,且为未修改前的提交
local 为 当前 master-1 已经提交并保存的了部分,也就是最终master-1的在硬盘内(LOCAL)的内容
remote 为当前 master-1 冲突待(REMOTE 在词典中可以翻译为相差很大的)提交的内容

相关推荐
程序大视界3 分钟前
2026AI智能体元年,中国正式超越美国
大数据·人工智能
qq_2351321733 分钟前
五金制造行业ERP系统多少钱?易呈erp五金行业版功能模块详解与成功案例分享
大数据·运维·人工智能·制造·智能制造
数字化顾问42 分钟前
(87页PPT)DG1165大数据平台建设方案技术交流(附下载方式)
大数据
jiang_changsheng1 小时前
亚马逊的(A9、COSMO)和视频推流(如ABR)点击推广算法
大数据·数据挖掘
小比特_蓝光1 小时前
版本控制器Git/调试器gdb/cgdb使用
git
切糕师学AI2 小时前
Elasticsearch 向量索引深度解析:从原理到生产实践
大数据·elasticsearch·搜索引擎·语义搜索·相似性搜索·语义理解
jinanwuhuaguo2 小时前
OpenClaw办公人员核心技能深度培训体系:从认知重塑到数字组织构建的全链路实战指南
java·大数据·开发语言·人工智能·openclaw
lifallen2 小时前
Flink Agents:从 DataStream 到 Agent 算子的接入与装配
java·大数据·人工智能·python·语言模型·flink
财经资讯数据_灵砚智能2 小时前
基于全球经济类多源新闻的NLP情感分析与数据可视化(日间)2026年4月5日
大数据·人工智能·python·信息可视化·自然语言处理·ai编程
J2虾虾2 小时前
Hadoop入门
大数据·hadoop·分布式