在不实际拉取的情况下检测父存储库和分支之间的冲突
我想解决以下问题: 我有一个存储库(称为 A)和它的克隆(称为 B)。我在 B 中做了一些更改,我想请 A 的所有者拉取它。我想实现一个函数,可以确定 B 中的更改是否可以拉到 A 而不会引起任何冲突。我想以一种不会破坏 A 中信息的方式来实现这一点(因此任何克隆 A 的人都会看到与此冲突检测之前完全相同的内容)。
请注意,我想以更有效的方式解决它。我看到 bitbucket 非常快地执行拉取请求检查。你有什么想法吗?
提前致谢
I'd like to solve the following problem:
I have a repository (call it A) and a clone of it (call it B). I made some changes in B and I want to ask the owner of A to pull it. I'd like to implement a function that can figure out if the changes in B can be pulled to A without causing any conflicts. I want to implement this in such a way that doesn't corrupt the information in A (so anyone who clones A sees exactly the same than before this confict detection).
Please note that I'd like to solve it the more efficient way. I saw that bitbucket performs this check for pull requests very fast. Do you have any idea?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
难道你不能创建 A 的另一个克隆并在那里进行合并吗?这样你就知道合并是如何进行的,并且不会搞乱 A。
Can't you just create another clone of A and do the merge there? This way you know how the merge went, and you don't mess up A.
首先,拉动本身不会产生任何冲突。它只是将变更集添加到存储库历史记录中,还可能添加新的分支/头。合并这些头时可能会发生冲突。因此,当A从B中拉出时,A中没有任何损坏。
但是,如果您希望 A 的所有者包含您的更改,那么您实际上需要做的是将 A 中的最近更改拉入您的 B > 并且 - 如果需要 - 将 A 中的新更改合并到您的新更改中。然后请求从现在合并的 B 中拉取,A 可以在不添加新头的情况下拉取,因此可能不必处理冲突。
如果您不想遵循常见的工作流程,但确实想按照问题中的描述进行检查,只需创建 A 的新克隆,比方说 C,然后尝试从B拉取并合并到C。但最终您还是会执行上述步骤。
First of all, a pull won't create any conflicts by itself. It just adds changesets to a repository history, possibly also adding new branches/heads. You might get conflicts when merging such heads. So when A pulls from B, there is nothing broken in A.
However, if you want the owner of A to include your changes, what you actually have to do is to pull recent changes from A into your B and - if needed - merge the new changes from A into your new changes. Then request a pull from your now merged B, which A can pull without adding new heads and thus without possibly having to deal with conflicts.
If you don't want to follow that common workflow but really want to check it as described in your question, just create a new clone of A, let's say C, and try to pull and merge from B into C. But finally you'll end up in the steps mentioned above anyway.