TFS分支,有什么优势 [英] TFS branching, what are the advantages

查看:147
本文介绍了TFS分支,有什么优势的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对TFS和源代码控制还很陌生。我无法理解分支的优势。因为我可以通过创建2个文件夹main和development来做同样的事情,所以当我完成development.I时,可以使用任何diff工具与main分支合并代码。

I am pretty new to TFS and source control. I unable to understand the advantage of branching. Since i can do the same stuff by creating 2 folder main and development, when I am done with development.I can merge the code using any diff tool with the main branch.

那么拥有分支的意义何在?我知道必须有巨大的优势,但我无法理解。

Then whats the point of having branches ? I know there must a huge advantage but i am unable to understand.

推荐答案

(更新:TFS现在支持git进行版本控制,因此此答案的其余部分不再适用)

(UPDATE: TFS now supports git for version control so the rest of this answer no longer applies)

我会按功能搜索google。

I would google branch-per-feature.

主要分支的优点是您可以使用某个功能,而不会被任何其他人的工作打扰。准备就绪后,您可以合并并查看许多功能是否可以很好地协同工作。通常是在开发功能时完成此操作,但是对于小型功能,只要完成功能即可完成。

The main advantage of branching is that you can work on a feature and not be interrupted by anyone else's work. When you are ready, you can merge and see if many features work well together or not. This is usually done as the feature is developed but for small features can be done once the feature is complete.

优点是您对自己的工作有清晰的历史记录实现一些东西。没有分支,您将有很多提交与其他功能的提交混在一起。如果质量检查未通过某个功能,则您的工作将被削减,以便仅使用其他功能的提交来组合另一个构建。另一种选择是尝试修复您的功能,以便通过质量检查。

The advantage is that you have a clear history of what you did to implement something. Without branches, you would have a whole lot of commits mixed together with other features' commits. If QA does not pass a certain feature, you have your work cut out for you to put together another build using just the commits for the other features. The other alternative is to try and fix your feature so that QA passes. This may not be doable on a Friday afternoon.

功能切换是省略工作的另一种方法,但这增加了代码的复杂性,并且切换本身可能存在错误。这是非常令人厌烦的事情,并看到它如何成为可接受的变通方法。

Feature toggles are another way to omit work but this increases the complexity of code and the toggles may themselves have bugs in them. This is something to be very weary of and see how this became an "acceptable" work-around.

分支还用于跟踪对发行版的多个版本的更改。由多个客户消费的产品可能处于一种状态,即一组客户正在使用产品的1.0,而其他一组客户已经在使用2.0。如果两者都支持,则应通过指定给它们的分支跟踪对每个分支的更改。前面的几点仍然适用于这些分支的开发。

Branches are also used to track changes to multiple versions of releases. Products that are consumed by multiple customers may be in a situation that one set of customers is using 1.0 of the product while others are already on 2.0. If you support both, you should track changes to each by branches that are designated to them. The previous points still apply to developing for these branches.

由于许多原因,TFS在每个功能的分支机构上都不理想。最大的缺点是它不支持三向合并-仅具有所谓的无基础合并。跟踪历史记录的方式,TFS无法向您显示要素分支与您尝试将其合并到的位置之间的共同祖先。这使您潜在地解决了许多冲突。通常,出于这个原因,很多使用TFS的人都避开分支。

Having said that, TFS is not ideal at branch-per-feature for a number of reasons. The biggest is that it does not support 3-way merges - it only has what is called a baseless merge. The way history is tracked, TFS cannot show you a common ancestor between the feature branch and where you are trying to merge it to. This leaves you potentially solving a lot of conflicts. In general, a lot of people that use TFS shy away from branching for this reason.

3向合并非常棒,因为它们会告诉您共同的祖先是什么,您的更改是什么,另一个分支的更改是什么。

3-way merges are great because they will show you what the common ancestor is, what your changes are and what the changes in the other branch are. This will allow you to make a very educated decision on how to resolve a conflict.

如果您必须使用TFS,我建议您使用git-tfs来解决冲突。利用三向合并和许多其他功能。其中一些内容包括:rerere,rebasing,模型断开连接,本地历史记录,bisect等。

If you have to use TFS, I would suggest using git-tfs to be able to take advantage of 3-way merges and many other features. Some of them include: rerere, rebasing, disconnected model, local history, bisect, and many many more.

Rebase非常有用,因为它允许您将功能更改为以另一个起点为基础,省略提交,一起挤压提交,拆分提交等。一旦准备好,您就可以将它们合并到Integration或Release分支中,具体取决于您决定的工作流程。

Rebase is very useful as it allows you to alter a feature to be based off of another starting point, omit commits, squash commits together, split commits, etc. Once ready you can them merge into an integration or release branch, depending on the workflow you decide upon.

Mercurial也是另一种可能更易于使用,但从长远来看不会那么强大的功能。

Mercurial is also another one that may be easier to use, but will not be as powerful in the long run.

如果有机会,与现代DVCS相比,由于很多限制,我强烈建议您不使用TFS进行源代码控制。

If you have the opportunity, I would highly recommend moving away from TFS for source control due to a lot of limitations when compared to modern day DVCS.

如果您有以下几点,可以参考想要有效地管理分支/合并:

Here is a nice set of guidelines to follow if you want to effectively manage branching/merging:

http://dymitruk.com/blog/2012/02/05/branch-per-feature/

希望如此帮助。

这篇关于TFS分支,有什么优势的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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