我想使用git rebase
來提交一系列提交併將它們應用於不同的根提交。例如,git rebase是否有等價的「git apply --reject」?
git rebase --onto root start finish
獲得基於root
從start
到finish
的提交。
當git的不能申請提交乾淨,它會更新文件顯示這樣的衝突(例如,從git的手冊):
Here are lines that are either unchanged from the common
ancestor, or cleanly resolved because only one side changed.
<<<<<<< yours:sample.txt
Conflict resolution is hard;
let's go shopping.
=======
Git makes conflict resolution easy.
>>>>>>> theirs:sample.txt
And here is another line that is cleanly resolved or unmodified.
程序員文件編輯它應在新的分支是什麼,然後運行git --rebase continue
以繼續添加來自源的提交。
但是,當文件在root
和start
之間有很多變化時,可能會有許多這樣的行,並且它們可能很難解釋。在這種情況下,人們可能更喜歡將「失敗的hunks」輸出到文件中,以便人們可以通讀原始提交中的更改(手動對所要更改的文件進行更改,然後運行git rebase --continue
以繼續添加提交)。
的git apply
的--reject
選項執行此操作:
--reject
For atomicity, git apply by default fails the whole patch and does
not touch the working tree when some of the hunks do not apply.
This option makes it apply the parts of the patch that are
applicable, and leave the rejected hunks in corresponding *.rej
files.
這也是patch
程序的行爲 - 這樣我就可以得到我想要先outputing與git show
提交,然後用patch
應用它。然而,當涉及許多提交時,這並不方便。
有沒有辦法做到這一點與git rebase
(或另一個git命令)?
您是否考慮過使用視覺差異/合併工具來幫助您解釋衝突標記?我使用Beyond Compare,我發現它爲我節省了很多時間來修復合併衝突。 –
我不知道他們是什麼。他們是否允許您指定大塊適用於文件的位置? (我已經重新組織了文件,並且git或補丁不知道在哪裏應用hunk,這就是爲什麼我想要手動完成所有工作。) –
你在使用什麼操作系統,Windows,OS X或Linux? –