Menu
Coddy logo textTech

What Is A Branch

Part of the Version Control section of Coddy's Terminal journey — lesson 28 of 58.

A branch in Git is just a movable pointer to a commit. The default branch is usually called main, and every commit you make on it advances that pointer forward.

Branches let you work on different lines of development at the same time without stepping on each other. You can:

  • Try out a risky idea on a side branch and abandon it cleanly
  • Build a new feature in isolation while main stays stable
  • Hand off work to a teammate by sharing a branch

You can list branches at any time with:

git branch

The branch you are currently on is shown with a * next to its name. Internally, Git tracks "the current branch" through the .git/HEAD file you saw earlier.

challenge icon

Challenge

Beginner

The folder is already a fully configured Git repo with one commit on the main branch. List the branches and print the result.

Cheat sheet

A branch in Git is a movable pointer to a commit. The default branch is usually called main.

List all branches with:

git branch

The current branch is marked with a *. Git tracks the current branch via the .git/HEAD file.

Try it yourself

Terminal
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Version Control