Git merge - 简单的合并?
如果基础和源具有相同的文件内容,并且目标分支/存储库有一些其他文件更改,那么它保留哪些内容,源文件还是目标文件?
详细解释
A
|
B
/ \
C D
假设在 A->B 边缘添加了一个文件,然后在 B->C 中再次删除了文件,而在 B->D 边缘则将其单独保留。
我们想要合并C和D。
如果共同祖先是A,它没有变化(所以A,C没有文件,B,D有文件),当合并C和D时
,会发生什么C(目的地)从 D 合并?
如果 D(目的地)从 C 合并会发生什么?
If the base and the source have the same file content, and the destination branch/repo has some other file changes, which content does it keep, the source or the destination file?
To explain in detail
A
|
B
/ \
C D
Suppose that a file was added on the A->B edge, and then removed again in B->C, while it was left alone on the B->D edge.
We want to merge C and D.
If the common ancestor is A which doesn’t have the change (so A,C don’t have the file & B,D has the file) when merging C and D.
What happens if C (destination) merges from D?
What happens if D (destination) merges from C?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
合并是对称的(除了合并最终在一个分支或另一个分支上这一事实之外)。它将应用双方的更改并报告在此过程中遇到的任何冲突的更改。在这种情况下,由于只有一侧发生了变化,因此最终结果将与发生变化的一侧看起来相同。
顺便说一句,您可以非常安全地尝试这些操作,看看它们会做什么;如果事情进展不顺利,只需撤消。不过,请务必注意链接文章底部的警告。
Merge is symmetric (aside from the fact that the merge ends up on one branch or the other). It will apply changes from both sides and report any conflicting changes it encounters in the process. In this case, since only one side has changes, the end result will look identical to the side that has the changes.
As an aside, you can try these operations quite safely to see what they will do; if things go pear-shaped, just undo. Be sure to note the caveats at the bottom of the linked article, though.