When should you branch?

后端 未结 12 1356
情深已故
情深已故 2020-11-22 04:24

When working with a SCM system, when should you branch?

相关标签:
12条回答
  • 2020-11-22 04:52

    Whenever you feel like it.

    You probably won't very frequently if you work with a centralized SCM since the branches are part of the official repository, and that doesn't really invite much experimentation, not to mention that merges really hurt.

    OTOH, there's no technical difference between a branch and a checkout in distributed SCMs, and merges are a lot easier. You'll feel like branching a whole lot more often.

    0 讨论(0)
  • 2020-11-22 04:57

    It depends on what type of SCM you're using.

    In the newer distributed versions (like git and mercurial), you're creating branches all the time and remerging anyway. I'll often work on a separate branch for a while just because someone's broken the build on the mainline, or because the network's down, and then merge changes back in later when it's fixed, and it's so easy to do that it's not even annoying.

    The document (short and readable) that most helped me understand what was going in in the distributed systems is: UnderstandingMercurial.

    In the older systems with a central repository, (like CVS, SVN and ClearCase), then it's a much more serious issue which needs to be decided at a team level, and the answer should be more like 'to maintain an old release whilst allowing development to continue on the main line', or 'as part of a major experiment'.

    The distributed model is much better, I think, and lacking only nice graphical tools to become the dominant paradigm. However it's not as widely understood, and the concepts are different, so it can be confusing for new users.

    0 讨论(0)
  • 2020-11-22 04:58

    There are various purposes for branching:

    1. Feature/bug branches. Dynamic and active branches that get moved back into the trunk when the feature/bugfix is complete.
    2. Static branches (tags in Subversion, though in essence just a 'normal branch'). They provide a static snapshot of say, a release. Even though they could be worked on, they remain untouched.
    0 讨论(0)
  • 2020-11-22 04:59

    There are several uses for branching. One of the most common uses is for separating projects that once had a common code base. This is very useful to experiment with your code, without affecting the main trunk.

    In general, you would see two branch types:

    • Feature Branch: If a particular feature is disruptive enough that you don't want the entire development team to be affected in its early stages, you can create a branch on which to do this work.

    • Fixes Branch: While development continues on the main trunk, a fixes branch can be created to hold the fixes to the latest released version of the software.

    You may be interested in checking out the following article, which explains the principles of branching, and when to use them:

    • Ned Batchelder - Subversion branching quick start
    0 讨论(0)
  • 2020-11-22 05:02

    When you need to make significant and/or experimental changes to your codebase, particularly if you want to commit intermediate changes, without affecting trunk.

    0 讨论(0)
  • 2020-11-22 05:02

    The need for branching may also arise:

  • when you want to provide a hotfix to a particular customer (say important) and you are unsure whether the fix will be part of future releases

0 讨论(0)
提交回复
热议问题