Best branching strategy when doing continuous integration?

后端 未结 12 556
温柔的废话
温柔的废话 2020-12-12 11:30

What is the best branching strategy to use when you want to do continuous integration?

  1. Release Branching: develop on trunk, keep a branch for each rel
12条回答
  •  借酒劲吻你
    2020-12-12 11:56

    I think either strategy can be used with continuous development provided you remember one of the key principles that each developer commits to trunk/mainline every day.

    http://martinfowler.com/articles/continuousIntegration.html#EveryoneCommitsToTheMainlineEveryDay

    EDIT

    I've been doing some reading of this book on CI and the authors make suggest that branching by release is their preferred branching strategy. I have to agree. Branching by feature makes no sense to me when using CI.

    I'll try and explain why I'm thinking this way. Say three developers each take a branch to work on a feature. Each feature will take several days or weeks to finish. To ensure the team is continuously integrating they must commit to the main branch at least once a day. As soon as they start doing this they lose the benefit of creating a feature branch. Their changes are no longer separate from all the other developer's changes. That being the case, why bother to create feature branches in the first place?

    Using branching by release requires much less merging between branches (always a good thing), ensures that all changes get integrated ASAP and (if done correctly) ensures your code base in always ready to release. The down side to branching by release is that you have to be considerably more careful with changes. E.g. Large refactoring must be done incrementally and if you've already integrated a new feature which you don't want in the next release then it must be hidden using some kind of feature toggling mechanism.

    ANOTHER EDIT

    There is more than one opinion on this subject. Here is a blog post which is pro feature branching with CI

    http://jamesmckay.net/2011/07/why-does-martin-fowler-not-understand-feature-branches/

提交回复
热议问题