Skip to content
BENIBIX Learn

Main Branch

Development🔀 Version ControlBranches and History

Also known as Default Branch, Master Branch, main, master

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

Think of it like

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

Example

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

Why it matters

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

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 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.
The main branch is the line along the top.

Common mistake

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

Key takeaways

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

Learn it properly