Git

名稱

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*,則它會依序處理它們,僅在合併返回非零退出碼時停止。

通常,這是透過一個腳本呼叫 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