# Main Branch

> The home branch of a repository. Work starts from it and merges back into it.

**Field:** Software Development  
**Category:** Version Control  
**Also known as:** Default Branch, Master Branch, main, master

## Think of it like

Think of it like the trunk of a tree. Every branch grows out of it and joins back to it.

## Definition

The main branch is the branch a repository treats as its home. New branches start from it, and finished work is merged back into it. It is usually called main, and older projects often call it master. Git itself still names it master by default, but plans to switch to main. Most teams keep it ready to ship at all times.

## Example

Lucy sets her default branch name once. Every new repository she makes now starts on main.

## Example code

```console
$ git config --global init.defaultBranch main
$ git init shop
Initialized empty Git repository in /home/lucy/shop/.git/
```

Set the default name once, and new repositories start on main.

## Why it matters

Everything else is measured against it. A broken main branch blocks the whole team.

## Common mistake

Pushing half-done work straight to it. Use a feature branch and merge when it is ready.

## Three principles

- **The home line.** Branches start and end here.
- **Keep it working.** It should always be ready to ship.
- **main or master.** Same idea, two names.

## Related terms

- [Branch](https://learn.benibix.com/term/development/branch)
- [Feature Branch](https://learn.benibix.com/term/development/feature-branch)
- [Branch Protection](https://learn.benibix.com/term/development/branch-protection)
- [Trunk-Based Development](https://learn.benibix.com/term/development/trunk-based-development)
- [Merge](https://learn.benibix.com/term/development/merge)

## Taught in

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

![A main branch runs along the top. A feature branch splits off it, gets two commits, and comes back three ways. Fast-forward: main had no new commits, so its label just slides forward to the feature's last commit. Squash merge, lit up: the two feature commits become one new commit on main. Merge commit: a new commit with two parents joins both lines.](https://learn.benibix.com/diagrams/dev3-branch-merges.svg)

---

Source: https://learn.benibix.com/term/development/main-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.
