我正在寻找一种 merge 策略,它允许我选择来 self 的分支的更改以及传入的更改。
尝试通过不同的线程进行搜索,但无法弄清楚如何执行此操作。
所以我的仓库中有多个分支。我需要将每个分支 merge 到本地 master,然后 merge 到代码审查者的远程等待批准。为了实现这一点,我首先从 master 进行 rebase ,然后快速 merge 到 master,这是标准工作流程。 代码主要由配置文件组成,这些多个分支在同一个地方有代码更改(比如添加一个新参数)这些参数从不相同但在同一个位置。 git 将它们作为冲突触发,但我想要它做的只是选择我在分支中的更改以及在 rebase 期间从 master 传入的更改。我知道所涉及的风险,但我有一个验证脚本可以检测重复项并提醒我异常情况。
因此最终目标是编写这些 merge 的脚本,并仅在验证脚本失败时进行干预。
感谢回复
最佳答案
默认 merge 算法(及其 various strategies )应该默认保留您的更改和传入的更改。
如“How does Git solve the merging problem?”中所述,
The important part of a merge is not how it handles conflicts (which need to be verified by a human anyway if they are at all interesting), but that it should meld the history together right so that you have a new solid base for future merges.
In other words, the important part is the trivial part: the naming of the parents, and keeping track of their relationship. Not the clashes.
关于git merge 选择我们的和他们的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7659643/