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 在词典中可以翻译为相差很大的)提交的内容

相关推荐
敲上瘾31 分钟前
Elasticsearch从入门到实践:核心概念到Kibana测试与C++客户端封装
大数据·linux·c++·elasticsearch·搜索引擎·全文检索
api_1800790546044 分钟前
请求、认证与响应数据解析:1688 商品 API 接口深度探秘
java·大数据·开发语言·mysql·数据挖掘
百锦再2 小时前
第5章 所有权系统
运维·git·python·eclipse·go·github·负载均衡
0和1的舞者4 小时前
网络通信的奥秘:网络层ip与路由详解(四)
大数据·网络·计算机网络·计算机·智能路由器·计算机科学与技术
WLJT1231231235 小时前
九寨:在山水间触摸生活的诗意
大数据·生活
DW_DROME7 小时前
git worktree (镜像站加速)
git
Elastic 中国社区官方博客8 小时前
在 Elasticsearch 中使用 Mistral Chat completions 进行上下文工程
大数据·数据库·人工智能·elasticsearch·搜索引擎·ai·全文检索
橙色云-智橙协同研发8 小时前
从 CAD 图纸到 Excel 数据:橙色云智橙 PLM 打造制造企业数字化协同新模式
大数据·功能测试·云原生·cad·plm·云plm·bom提取
喝可乐的希饭a9 小时前
Elasticsearch 的 Routing 策略详解
大数据·elasticsearch·搜索引擎
_李小白9 小时前
【OPENGL ES 3.0 学习笔记】延伸阅读:VAO与VBO
笔记·学习·elasticsearch