如何处理使用git主题分支工作流时的依赖关系? [英] How to handle dependencies when using git topic branch workflow?

查看:227
本文介绍了如何处理使用git主题分支工作流时的依赖关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的项目中,我们试图保持与官方git工作流程接近,如下所示:
http://www.kernel.org/pub/software/scm/git/docs/gitworkflows.html



我们使用 master next 分支,从 master ,定期测试集成到 next 中,如果分支完成,我们将它合并到 master



现在有时会发生, topic-X 有一些发展。开发人员创建 somefile.c 并添加他需要的代码。过了一段时间,另一个开发人员在 topic-Y 上工作,发现他还需要创建 somefile.c 和甚至会需要来自 topic-X 的文件的某些部分 - 但不是完整的文件,因为它还包含代码,它只与主题相关-X 。如果 topic-X 会完成并合并到其他代码中,则可能需要添加其他代码到该文件中。 master ,这很容易:我们可以将 topic-Y 转换为 master 使该代码可用。但是,如果两个主题仍然不完整?



因为 topic-X topic -Y 真的不相关,除了 somefile.c 中的这个次要共享代码之外,我们如何避免将它们合并到彼此中并仍然提供这两个开发人员共享 somefile.c



部分的共享部分如果我们创建一个新的 somefile.c topic-Y 中只有相关部分,我们发现我们稍后会收到合并冲突, 。有没有其他的办法?

解决方案

最好在分支中合并X和Y的公共基础, code> topic-x topic-y 。那么最佳的情况是,两个分支都不会再触及 somefile.c ,而是说 somefile-xc somefile-yc only。



或者使用更高级的工具,如 topgit 可能会帮助你(或不是: - ))


In our project we try to stay close to the "official" git workflow as it is suggested here: http://www.kernel.org/pub/software/scm/git/docs/gitworkflows.html

We use a master and next branch, start our topic branches off from master, regularly do test integration into next, and if a branch is complete, we merge it into master.

Now sometimes it happens, that there's some development on topic-X. A developer creates somefile.c and adds code there that he needs for his topic. After a while another developer works on topic-Y and finds out, that he also needs to create somefile.c and even would need some parts of that file from topic-X - but not the complete file, as it also contains code, which is only related to topic-X. He may also have to add other code to that file.

If topic-X would be complete and merged into master, it would be easy: We could rebase topic-Y to master to make that code available. But what, if both topics are still incomplete?

Because topic-X and topic-Y are really unrelated, except for this minor shared code in somefile.c, how can we avoid to merge them into each other and still provide both developers with the shared parts from somefile.c?

If we create a fresh copy of somefile.c in topic-Y with only the relevant parts, we found that we get merge conflicts later, when we do test integration in next. Is there any alternative?

解决方案

It would be best to consolidate a common base for X and Y in a branch and base both topic-x and topic-y on that one. Then optimally both branches would not touch somefile.c any more, but say somefile-x.c and somefile-y.c only.

Alternatively a more advanced tool like topgit might help you (or not :-))

这篇关于如何处理使用git主题分支工作流时的依赖关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆