問題:
Assuming I am the maintainer of a repo, and I want to pull in changes from a contributor, there are a few possible workflows: 假設我是回購的維護者,並且我想從貢獻者那裏獲取更改,那麼有一些可能的工作流程:
- I
cherry-pick
each commit from the remote (in order). 我從遠程中cherry-pick
每個提交(按順序)。 In this case git records the commit as unrelated to the remote branch. 在這種情況下,git將提交記錄爲與遠程分支無關。 - I
merge
the branch, pulling in all changes, and adding a new "conflict" commit (if needed). 我merge
分支,拉入所有更改,並添加新的“衝突”提交(如果需要)。 - I
merge
each commit from the remote branch individually (again in order), allowing conflicts to be recorded for each commit, instead of grouped all together as one. 我merge
遠程分支中的每個提交單獨merge
(再次按順序),允許爲每個提交記錄衝突,而不是將所有提交組合爲一個。 - For completeness, you could do a
rebase
(same ascherry-pick
option?), however my understanding is that this can cause confusion for the contributor. 爲了完整性,你可以做一個rebase
(與cherry-pick
選項相同?),但是我的理解是這會導致貢獻者的混淆。 Maybe that eliminates option 1. 也許這消除了選項1。
In both cases 2 and 3, git records the branch history of the commits, unlike 1. 在情況2和3中,git記錄了提交的分支歷史記錄,與1不同。
What are the pro's and con's between using either cherry-pick
or merge
methods described? 使用所描述的cherry-pick
或merge
方法之間有什麼優點和缺點? My understanding is that method 2 is the norm, but I feel that resolving a large commit with a single "conflict" merge, is not the cleanest solution. 我的理解是方法2是常態,但我覺得用單個“衝突”合併解決大型提交併不是最乾淨的解決方案。
解決方案:
參考一: https://stackoom.com/question/5D1k參考二: Git Cherry-pick vs Merge Workflow