名称

git-merge-index - 运行合并文件所需的合并

概要

git merge-index [-o] [-q] <merge-program> (-a | ( [--] <file>…​) )

描述

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

选项

--

不要将更多参数解释为选项。

-a

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

-o

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

-q

不要抱怨失败的合并程序(合并程序失败通常表示合并期间存在冲突)。这适用于可能希望发出自定义消息的瓷器。

如果使用多个 <file>(或 -a)调用 *git merge-index*,则它会依次处理它们,仅当 merge 返回非零退出代码时才停止。

通常,这是通过脚本调用的 Git 对 RCS 包中的 *merge* 命令的模仿来运行的。

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

警报!警报!警报!Git "合并对象顺序"与 RCS *merge* 程序合并对象顺序不同。在上面的排序中,原始对象排在第一位。但是 3 向合并程序 *merge* 的参数顺序是将原始对象放在中间。不要问我为什么。

示例

torvalds@ppc970:~/merge-test> git merge-index cat MM
This is MM from the original tree.		# original
This is modified MM in the branch A.		# merge1
This is modified MM in the branch B.		# merge2
This is modified MM in the branch B.		# current contents

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