Feature Branch
A branch created to develop one change in isolation before merging it back, a workflow that keeps the main line stable but grows riskier the longer the branch lives, since its divergence from everyone else's work compounds.
A feature branch is a branch created to develop one change, such as a new feature or a bug fix, separately from the main line of a project. The developer commits to it freely, and when the work is done it's merged back. Until then, unfinished work stays out of the code everyone else depends on; see Branching Model.
Feature branches became the default way of working once distributed version control made branches cheap. In older centralized systems, branching was slow and merging was painful, so teams branched rarely. Git made a branch little more than a pointer to a commit, and hosting platforms built their review flow around them: open a branch, push it, and propose merging it; see Pull Request.
The appeal is real. Each branch is a natural unit of review. Half-built work never breaks the main line, and an abandoned idea can simply be deleted. Several people can work on unrelated changes without stepping on each other. Branches are usually named for their purpose, often with a prefix such as feature or fix and an issue number, so tooling can link them to tracked work.
The trouble is time. A branch records the main line as it was when the branch was created. Every day it stays open, other people merge their own work, and the branch's view of the codebase grows staler. When it finally merges, all of that divergence must be reconciled at once. Textual conflicts are the visible part. The worse part is changes that merge cleanly but no longer fit together, such as a renamed function called from new code the other branch added; see Merge Conflict and Semantic Conflict. Teams that let many branches live for weeks end up in what's called integration hell, where merging takes longer than the features did. This was the problem continuous integration was originally named to solve: integrate everyone's work at least daily so divergence can't pile up.
Remedies mostly shrink the branch's lifetime. Keeping branches to a day or two keeps merges small. Merging the main line into the branch, or rebasing onto it, regularly keeps the branch current. Large changes can be split into a sequence of small reviewable steps; see Stacked Pull Requests.
At the far end is trunk-based development, where branches last hours if they exist at all and unfinished features ship hidden behind a Feature Flag. Long-lived branches still have legitimate uses, such as maintaining an old release line, where divergence is intended; see Long-Term Support.
See also3
Three-Way Merge
Combining two lines of work by comparing both against their common ancestor.
Version Control & Delivery17 connections
Squash Merge
Collapsing a branch's commits into one before merging, trading granularity for a clean main history.
Version Control & Delivery24 connections
Merge Train
Validating changes against the state they will actually merge into, in order, rather than in isolation.
Version Control & Delivery14 connections
Linked from10
- Fast-Forward MergeVersion Control & Delivery
The two basic ways Git joins branches, by sliding a branch pointer forward or by recording a new commit with two parents, and how the choice shapes a project's history.
- Force PushVersion Control & Delivery
Overwriting a remote branch with local history that doesn't contain it, the operation that makes rewritten history shareable and silently deletes other people's work when used carelessly.
- Long-Term SupportVersion Control & Delivery
A release line that receives security and bug fixes for years instead of months, letting users who value stability skip the constant upgrade treadmill.
- Merge ConflictVersion Control & Delivery
Overlapping changes that a merge cannot combine automatically, requiring a decision.
- Merge TrainVersion Control & Delivery
Validating changes against the state they will actually merge into, in order, rather than in isolation.
- RebaseVersion Control & Delivery
Replaying a branch's commits onto a new base, producing new commits with the same changes.
- Semantic ConflictVersion Control & Delivery
Two changes that merge cleanly and are incompatible in meaning.
- Squash MergeVersion Control & Delivery
Collapsing a branch's commits into one before merging, trading granularity for a clean main history.
- Stacked Pull RequestsVersion Control & Delivery
A chain of dependent changes, each reviewed separately and merged in order.
- Three-Way MergeVersion Control & Delivery
Combining two lines of work by comparing both against their common ancestor.