Optimization glossary

Feature branch

What is a feature branch?

A feature branch is a copy of the main codebase where an individual or team of software developers can work on a new feature until it is complete.

With many engineers working in the same code-base, it's important to have a strategy for how individuals work together. To avoid overriding each other's changes, engineers create their own copy of the codebase, called branches. Following an analogy of a tree, the master branch is sometimes called the trunk. The process of incorporating the changes of an individual's copy into the main master trunk is called merging.

Feature branch development process

In feature branch development, individual engineers or teams of engineers do not merge their branch until a feature is complete, sometimes working for weeks or months at a time on a separate copy. This long stretch of time can make the process of merging difficult because the trunk or master has likely changed due to other engineers merging their branches. This is known as a merge conflict.

Feature branch development and merging source code is handled in version control software such as Git and Github. The main branch and feature branches live in this code repository (or repo) and developers checkout code to create a new branch to work from.

Once the changes are made to the code, the developer makes what is known as a pull request, or a request to have other developers on the team do a code review to ensure that the local branch does not have any errors, and also that it will not cause any errors when merged into the main branch. Once a branch has been thoroughly reviewed, it can then be merged into the main branch.

Feature branch development is one method of managing many engineers working off of the same codebase. Modern teams often rely on continuous integration and trunk-based development to avoid issues with bug fixes and merge conflicts that arise from the branching model of code development.

Continuous integration and feature branches

One alternative to the feature branch workflow is continuous integration, which is a software development methodology which involves continuously integrated new code changes into the mainline or trunk rather than waiting until a new feature branch has been under development for weeks or months and has diverged from the main branch.

Continuous integration, also known as trunk-based development helps to minimize merge conflicts by continually merging changes into a single source to prevent feature branching. Continuous integration, along with practices such as feature flagging can help developers to deploy code faster with less time spent trying to reconcile different versions of code.