让我们重复设置:
$ git clone https://github.com/antlr/antlr4
Cloning into 'antlr4'...
remote: Enumerating objects: 2, done.
remote: Counting objects: 100% (2/2), done.
remote: Compressing objects: 100% (2/2), done.
^Rceiving objects: 21% (24258/115511), 16.64 MiB | 3.15 MiB/s /s
remote: Total 115511 (delta 0), reused 0 (delta 0), pack-reused 115509
Receiving objects: 100% (115511/115511), 61.89 MiB | 3.13 MiB/s, done.
Resolving deltas: 100% (67916/67916), done.
$ git checkout -b tmp 103dc662c
到目前为止一切正常。现在我们将得到合并冲突以及许多我们应该注意的消息:
$ git merge 31d21ff4d
Auto-merging tool/resources/org/antlr/v4/tool/templates/codegen/Go/Go.stg
CONFLICT (content): Merge conflict in tool/resources/org/antlr/v4/tool/templates/codegen/Go/Go.stg
Auto-merging runtime/Go/src/antlr/Utils.go
Auto-merging runtime/Go/src/antlr/Trees.go
Auto-merging runtime/Go/src/antlr/Tree.go
Auto-merging runtime/Go/src/antlr/Transition.go
CONFLICT (rename/delete): runtime/Go/src/antlr4/TraceListener.go deleted in HEAD and renamed to runtime/Go/src/antlr/TraceListener.go in 31d21ff4d. Version 31d21ff4d of runtime/Go/src/antlr/TraceListener.go left in tree.
Auto-merging runtime/Go/src/antlr/TokenStream.go
Auto-merging runtime/Go/src/antlr/TokenSource.go
Auto-merging runtime/Go/src/antlr/Token.go
Auto-merging runtime/Go/src/antlr/SemanticContext.go
Auto-merging runtime/Go/src/antlr/RuleContext.go
Auto-merging runtime/Go/src/antlr/Recognizer.go
Auto-merging runtime/Go/src/antlr/PredictionMode.go
Auto-merging runtime/Go/src/antlr/PredictionContext.go
Auto-merging runtime/Go/src/antlr/ParserRuleContext.go
Auto-merging runtime/Go/src/antlr/ParserATNSimulator.go
Auto-merging runtime/Go/src/antlr/Parser.go
Auto-merging runtime/Go/src/antlr/LexerActionExecutor.go
Auto-merging runtime/Go/src/antlr/LexerAction.go
Auto-merging runtime/Go/src/antlr/LexerATNSimulator.go
Auto-merging runtime/Go/src/antlr/Lexer.go
Auto-merging runtime/Go/src/antlr/LL1Analyzer.go
Auto-merging runtime/Go/src/antlr/IntervalSet.go
Auto-merging runtime/Go/src/antlr/IntStream.go
Auto-merging runtime/Go/src/antlr/InputStream.go
Auto-merging runtime/Go/src/antlr/FileStream.go
Auto-merging runtime/Go/src/antlr/Errors.go
Auto-merging runtime/Go/src/antlr/ErrorStrategy.go
CONFLICT (content): Merge conflict in runtime/Go/src/antlr/ErrorStrategy.go
Auto-merging runtime/Go/src/antlr/ErrorListener.go
Auto-merging runtime/Go/src/antlr/DiagnosticErrorListener.go
Auto-merging runtime/Go/src/antlr/DFAState.go
Auto-merging runtime/Go/src/antlr/DFASerializer.go
Auto-merging runtime/Go/src/antlr/DFA.go
Auto-merging runtime/Go/src/antlr/CommonTokenStream.go
Auto-merging runtime/Go/src/antlr/CommonTokenFactory.go
Auto-merging runtime/Go/src/antlr/CharStream.go
Auto-merging runtime/Go/src/antlr/ATNType.go
Auto-merging runtime/Go/src/antlr/ATNState.go
Auto-merging runtime/Go/src/antlr/ATNSimulator.go
Auto-merging runtime/Go/src/antlr/ATNDeserializer.go
Auto-merging runtime/Go/src/antlr/ATNDeserializationOptions.go
Auto-merging runtime/Go/src/antlr/ATNConfigSet.go
Auto-merging runtime/Go/src/antlr/ATNConfig.go
Auto-merging runtime/Go/src/antlr/ATN.go
Removing pb/src/parser/T.g4
Removing pb/src/parser/T.g
Removing pb/src/parser/S.g4
Removing pb/src/parser/M.g4
Removing pb/src/parser/JSON.g4
Removing pb/src/parser/Expr.g4
Removing pb/src/parser/Arithmetic.g4
Removing pb/src/parser/.gitignore
Removing pb/src/input
Removing pb/src/Test.go
Removing antlr.go
Automatic merge failed; fix conflicts and then commit the result.
注意前面提到的重命名/删除冲突:
CONFLICT (rename/delete): runtime/Go/src/antlr4/TraceListener.go deleted in HEAD
and renamed to runtime/Go/src/antlr/TraceListener.go in 31d21ff4d. Version
31d21ff4d of runtime/Go/src/antlr/TraceListener.go left in tree.
(我添加的换行符)。
当我尝试打开父版本中的原始文件时,左侧版本中的文件...存在,
这很好,但是很明显至少一侧重命名了至少 一些 个文件,我们应该预料到这些文件在三个输入提交中可能具有不同的名称。
...正确版本的文件...在路径runtime/Go/src/antlr/ErrorStrategy.go中。
我在runtime/Go/src/antlr/ErrorStrategy.go、MERGE_HEAD aka 31d21ff4db8ddcf76bae1b865cd568621bfd5b4d 中找到了这个。
然而,在 merge base 提交中:
$ git merge-base --all HEAD MERGE_HEAD
3406acabe51e89c57fc26aca02aeb7cbc30119bd
仓库在runtime/Go/src/antlr4/ErrorStrategy.go:
git ls-tree -r 3406acabe51e89c57fc26aca02aeb7cbc30119bd | grep ErrorStrategy.go
100644 blob aed0ef94b5409f8035897496610446a5cbb52ef2 runtime/Go/src/antlr4/ErrorStrategy.go
换句话说,这两个合并输入提交似乎都遵循了相同的重命名模式。从合并基础到 HEAD 的差异,以及从合并基础到 31d21ff4d 的差异,都将 antl4 子目录重命名为 antlr。
这一切都很正常。如果您正在执行手动合并解析,您可能会发现将merge.conflictStyle 设置为diff3 很有帮助。如果您希望让 Git 为您查找文件,请考虑使用 git mergetool 提取输入文件:它应该会自动为您查找合并基础、HEAD 和 MERGE_HEAD 文件。