Fundamentals

Branch

A branch is a separate line of development in Git, letting you work on a feature or a fix without disturbing the stable version.

A separate line of work

A branch splits Git’s history into a separate line of development, so you can build a feature or a fix while the published, stable state stays intact.

Git’s own glossary calls it a line of development. For beginners it helps to think of it not as a heavy copy of the project but as a lightweight marker pointing at a place in the history.

The main branch and working branches

Most repositories name their central branch main. To make a change you create a working branch such as feature/search or fix/header, then merge it back into main when it is ready.

Naming conventions vary by project. master used to be standard; main is now the common default.

Why use them

  • Unfinished work stays separate from the stable version
  • Several pieces of work can proceed in parallel
  • Pull requests give a reviewable unit of change
  • A problematic change can be stopped before it reaches the main line

Check which branch you are on

Commits go to whichever branch is currently checked out. Working without noticing you are on the wrong one puts changes into a history you did not intend.

Before committing or pushing, check Current Branch in GitHub Desktop or SourceTree, or run git status.

Switching branches also changes the files in your working folder to match. If uncommitted changes would conflict, Git may stop the switch. Commit, stash, or discard your current work before moving.

A branch is a line of commits, not a backup. Creating one because work is important is not the same as protecting it — consider pushing to the remote or taking a separate backup as well.

Related terms

Sources and review information

Last reviewed July 21, 2026

Back to the AI Glossary

Search this site