根据你的之前的评论 https://stackoverflow.com/questions/15277708/how-do-you-see-show-a-git-merge-conflict-resolution-that-was-done-given-a-mer/71181334#comment134876296_71181334,我建议查看合并提交(Git 2.36+,2022 年第 2 季度):
git log --remerge-diff <rev>^!
With ^!父简写概念 https://git-scm.com/docs/git-rev-parse#_other_rev_parent_shorthand_notations being:
The r1^!
符号包括提交r1
但不包括其所有父母。
就其本身而言,此符号表示单个提交r1
.
<rev>
is a "revision https://git-scm.com/docs/git-rev-parse#_specifying_revisions",通常命名提交对象。
你会替换<rev>
(包括<
and >
) with:
- 提交 SHA1
- 或分支名称(“refname”)
-
@
(HEAD 的快捷方式)
- ...
在每种情况下,在这个问题的背景下,<rev>
必须代表一个合并提交,(最常见的)有 2 个父母的提交。
That <rev>
commit 代表两个父级之间合并的结果。
我如何查看合并期间哪些特定文件发生冲突的历史信息(一个人必须解决的文件)?
为此,您需要Git 2.38,2022 年第 3 季度 https://stackoverflow.com/a/73091924/6309:
# You can list the files with conflicts and why they are in conflicts:
git merge-tree --write-tree --no-messages branch1 branch2
# You can list the files with conflicts (just their names):
git merge-tree --write-tree --no-messages --name-only branch1 branch2
你会替换branch1
and branch2
通过你的承诺<rev>
父母:
git merge-tree --write-tree --no-messages --name-only <rev>^1 <rev>^2
After 讨论 https://chat.stackoverflow.com/rooms/254119/discussion-between-vonc-and-max,OP 在给定的 3 个命令之后merge_commit_sha
:
-
要查看某人尝试合并时看到的内容,合并冲突 - 作为与非冲突+冲突文件的巨大差异 - 在该人解决任何冲突并进行合并提交之前
git merge-tree --write-tree --no-messages --name-only merge_sha^1 merge_sha^2
-
查看合并冲突解决和合并提交期间发生的事实差异(人员可以添加一些修复甚至新文件)
git show --diff-merges=dense-combined merge_sha
-
查看带有合并提交的存储库发生的批量更改(合并提交更改本身+自提交发生分歧以来,所有组合更改都发生在 2 个分支中)
git diff $(git merge-base merge_sha^1 merge_sha^2) merge_sha"
我还想补充一下git diff AUTO_MERGE
,Git 2.42(2023 年第 3 季度)记录了更多伪引用,包括AUTO_MERGE
.
See commit 982ff3a https://github.com/git/git/commit/982ff3a649221d9db79049e5823425f645b3228e, commit 4fa1edb https://github.com/git/git/commit/4fa1edb98820ec6ddf52b004f9d616c34a8ddfd2, commit b7dd54a https://github.com/git/git/commit/b7dd54a2c7df5e1dbe713807afb49fb77c9b7fc7, commit 1ef3c61 https://github.com/git/git/commit/1ef3c61b7889e2aa76a8f0d32a88fbc09fca3b8e, commit 6ec5f46 https://github.com/git/git/commit/6ec5f46071f793dbfa0915212b5708e2ce017053, commit bc11bac https://github.com/git/git/commit/bc11bac3291c4cbeb4fb475c4fdc6fe3b22ba12e (22 May 2023) by Philippe Blain (phil-blain) https://github.com/phil-blain.
(Merged by Junio C Hamano -- gitster -- https://github.com/gitster in commit 0899beb https://github.com/git/git/commit/0899beb63c525c8254b2367e879cc8744092243f, 20 Jun 2023)
Documentation https://github.com/git/git/commit/4fa1edb98820ec6ddf52b004f9d616c34a8ddfd2: 文档AUTO_MERGE
Signed-off-by: Philippe Blain
Signed-off-by: Junio C Hamano
Since 5291828 https://github.com/git/git/commit/5291828df8386ebeb01039d1403d9f845d2f6e20 ("merge-ort
: write $GIT_DIR/AUTO_MERGE
每当我们遇到冲突时”,2021-03-20,Git v2.32.0-rc0 --merge https://github.com/git/git/commit/7bec8e7fa6175f51e79c55e28e6b2a547a986926),当使用 'ort' 合并策略时,特殊的 refAUTO_MERGE
当合并操作导致冲突时写入。
该引用指向记录工作树冲突状态的树,在解决冲突期间非常有用。
然而,这个参考文献没有记录。
添加一些文档AUTO_MERGE
在 git-diff(1)、git-merge(1)、gitrevisions(7) 和用户手册中。
Also mention AUTO_MERGE
in the "How to resolve conflicts" section, when mentioning 'git diff https://github.com/git/git/blob/4fa1edb98820ec6ddf52b004f9d616c34a8ddfd2/Documentation/git-diff.txt'(man https://git-scm.com/docs/git-diff).
Closes: https://github.com/gitgitgadget/git/issues/1471 https://github.com/gitgitgadget/git/issues/1471
git diff
现在包含在其man page https://github.com/git/git/blob/4fa1edb98820ec6ddf52b004f9d616c34a8ddfd2/Documentation/git-diff.txt#L105-L109:
感兴趣的树是所指向的树
由特别裁判AUTO_MERGE
,由 'ort' 合并编写
遇到合并冲突时的策略(参见git merge https://git-scm.com/docs/git-merge)。
比较工作树AUTO_MERGE
显示您迄今为止为解决文本冲突所做的更改(请参阅下面的示例)。
$ git diff AUTO_MERGE
:到目前为止,您为解决文本冲突而对工作树所做的更改。
git merge
现在包含在其man page https://github.com/git/git/blob/4fa1edb98820ec6ddf52b004f9d616c34a8ddfd2/Documentation/git-merge.txt#L199-L203:
- 特别参考
AUTO_MERGE
写着,指向一棵树
对应于工作树的当前内容(包括
文本冲突的冲突标记)。
请注意,此参考仅
当使用“ort”合并策略(默认)时编写。
revisions
现在包含在其man page https://github.com/git/git/blob/4fa1edb98820ec6ddf52b004f9d616c34a8ddfd2/Documentation/revisions.txt#L75-L78:
AUTO_MERGE
:
记录状态对应的树对象
'ort' 合并策略在合并操作时写入工作树
导致了冲突。
user-manual
现在包含在其man page https://github.com/git/git/blob/4fa1edb98820ec6ddf52b004f9d616c34a8ddfd2/Documentation/user-manual.txt#L1346-L1372:
当使用“ort”合并策略(默认)时,在更新工作之前
树与合并的结果,Git 编写一个特殊的引用,名为AUTO_MERGE
反映即将写入的树的状态。
与以下路径有冲突
无法自动合并的文本冲突写入此
带有冲突标记的树,就像在工作树中一样。
因此 AUTO_MERGE 可以是
与一起使用git diff https://git-scm.com/docs/git-diff显示您迄今为止所做的需要解决的更改
冲突。
使用与上面相同的示例,解决冲突后我们
得到:
$ git diff AUTO_MERGE
diff --git a/file.txt b/file.txt
index cd10406..8bf5ae7 100644
--- a/file.txt
b/file.txt
@@ -1,5 +1 @@
-<<<<<<< HEAD:file.txt
-Hello world
-=======
-Goodbye
->>>>>>> 77976da35a11db4580b80ae27e8d65caf5208086:file.txt
Goodbye world
请注意,差异显示我们删除了冲突标记和内容行的两个版本,并写入“Goodbye world
“ 反而。
The OP Max https://stackoverflow.com/users/336184/max添加评论 https://stackoverflow.com/questions/76495313/replicate-intellij-merge-commit-details-functionality-in-cli-vanilla-git/76496753?noredirect=1#comment135121138_76496753:
其实我发现git merge-base
does not当定期合并到分支时可以正常工作B
从分行A
在我们最终合并之前B
into A
.
所以看来我们找不到“带来的变化”A
在最终合并中B
to A
" using git merge-base
在一般情况下。
See "Git:如何找到分支源自的提交哈希 https://stackoverflow.com/q/3998883/6309#comment4283509_3999084".