# Branch

> A line of work to one side. Try changes there while main stays safe.

**Field:** Software Development  
**Category:** Version Control  
**Also known as:** Git Branch, git switch

## Think of it like

Think of it like a side path off a main road. You can walk it, then join the road again later.

## Definition

A branch is a separate line of work inside one repository. You make a branch to try a feature or fix a bug without touching the main code. Commits on a branch stay there until you merge them back. The main line is often called main. Making a branch is quick and cheap in Git, so teams make one for almost every task.

## Example

Emma makes a branch called dark-mode. She tries a new look for a week, while main stays safe for everyone else.

## Example code

```console
$ git switch -c dark-mode
Switched to a new branch 'dark-mode'
$ git branch
* dark-mode
  main
```

A new branch, and the star shows which one you are on.

## Why it matters

Branches let many people work at once. Half-done work never breaks the main code.

## Common mistake

Letting a branch run for weeks. The longer it lives, the harder it is to merge back.

## Three principles

- **Work apart.** Changes stay off the main line.
- **Cheap to make.** One command, one second.
- **Merge back.** Finished work joins main again.

## Related terms

- [Merge](https://learn.benibix.com/term/development/merge)
- [Git HEAD](https://learn.benibix.com/term/development/head)
- [Commit](https://learn.benibix.com/term/development/commit)
- [Pull Request](https://learn.benibix.com/term/development/pull-request)
- [Main Branch](https://learn.benibix.com/term/development/main-branch)
- [Feature Branch](https://learn.benibix.com/term/development/feature-branch)

## Told apart from

- [Git Tag vs Branch](https://learn.benibix.com/compare/git-tag-vs-branch): People think a tag is just another kind of branch, since both are names on a commit. A branch moves forward each time you commit on it. A tag never moves, so v1.0 points at the same code years later. Tags also need a push of their own, because a plain git push does not send them.

## Taught in

- [Git Branches and HEAD](https://learn.benibix.com/learn/development-version-control/git-branches-and-head): Git and GitHub, 4/13

---

Source: https://learn.benibix.com/term/development/branch
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
