Continuous Integration vs Feature Branches

After reading the Continuous Delivery Book, I have been thinking a lot about branching strategies and Continuous Integration versus Feature Branching. I put together this little chart of the pros and cons of each.

Feature BranchingContinuous Integration
TrustDoes not require trust. You can control via GitLab who can merge into main branch. Great for open source projects and other low-trust environments.Requires some trust since anyone can check into main.
Knowledge DistributionPull/Merge Requests (PRs) can serve as a built-in code review that helps to distribute knowledge.By continuously integrating with others code you become more aware of what others are working on.
MergingYou avoid having frequent merges by creating branches and playing in your own sandbox. However when you do have to merge at the end of a feature, it can be quite painful, particularly if the feature branch is long-lived. Merges can be more difficult if someone other than the original author performs the merge.You do end up merging a lot, but most of them are small and relatively painless.Also because you are doing it often, the code is often fresh in your mind, so that makes resolving conflicts easier.
Ease of Releasing New FeaturesCan be quite painful. Merging a long-lived feature branch into main can be quite difficult. Depending on how you set up PRs, they could become a bottlekneck (ie if only 1 person can approve merging into main).Easy, since you have been integrating them all along. To avoid the user encountering half-finished features, you can use the Keystone Pattern.
RefactoringDiscourages refactoring outside your immediate feature, because it may take a while to merge those changes back in, increasing the chance of a conflict. Even if your merge is successful, others also have long-lived branches as well, so there is more potential for conflicts when they merge their changes in.Encourages refactoring, because you simply merge your refactorings back into the mainline immediately. Everyone is in the habit of pulling frequently, so the chances of conflicts are less.

2 Comments on “Continuous Integration vs Feature Branches

  1. Hi Sam.
    About that, I don’t see those as two separate things. I think they are more of a complement of each other. In fact, they tend to converge.
    I haven’t had the opportunity (time) to write about something about what I am testing here, but I don’t like and have never used gitflow either.
    It is very similar to “streamline flow”, you can find articles. But it is based on feature branches merging in main branches with fast-forward merges. This keep history cleans, and in fact, you end up having only one line in your repository.
    I’ve been also “squashing” commits, so I tend to care only about one very good written commit message during the merge process.

Leave a Reply

Your email address will not be published. Required fields are marked *