Git

名称

git-merge-index - 对需要合并的文件进行合并

概述

git merge-index [-o] [-q] <合并程序> (-a | ( [--] <文件>…​) )

描述

它会查找索引中的 <文件> 文件,如果有合并条目,则将这些文件的 SHA-1 哈希值作为参数 1、2、3(如果没有文件则为空参数)和 <文件> 作为参数 4 传递。 三个文件的文件模式作为参数 5、6 和 7 传递。

选项

--

不将之后的参数解释为选项。

-a

针对索引中需要合并的所有文件运行合并。

-o

不要在第一次合并失败时就停止,而是一次性完成所有合并—​即使之前的合并返回错误,也要继续合并,并且只在所有合并后返回错误代码。

-q

不要抱怨合并程序失败(合并程序失败通常表示合并过程中发生冲突)。这适用于可能希望发出自定义信息的上层命令。

如果调用 git merge-index 时有多个 <文件>s (或 -a),那么只有在 merge 返回非零退出代码时,才会依次处理它们。

通常情况下,运行脚本时会调用 RCS 软件包中 Git 的 merge 命令。

发行版中包含一个名为 git merge-one-file 的示例脚本。

警报 警报Git 的 “合并对象顺序” 与 RCS 的 merge 程序合并对象顺序不同。在上述顺序中,原始文件在前。但三方合并程序 merge 的参数顺序是把原始文件放在中间。别问我为什么。

实例:

torvalds@ppc970:~/merge-test> git merge-index cat MM
This is MM from the original tree.		# 初分支
This is modified MM in the branch A.		# 合并1
This is modified MM in the branch B.		# 合并2
This is modified MM in the branch B.		# 现在的内容

torvalds@ppc970:~/merge-test> git merge-index cat AA MM
cat: : No such file or directory
This is added AA in the branch A.
This is added AA in the branch B.
This is added AA in the branch B.
fatal: merge program failed

后一个例子说明了 git merge-index 如何在出现错误时停止合并(即 cat 对 AA 文件返回错误,因为它在原始文件中并不存在,因此 git merge-index 甚至没有尝试合并 MM 文件)。

GIT

属于 git[1] 文档

scroll-to-top