CurriculumBranching & MergingWhat is a Branch?
Lesson 1 of 520%
Beginner5 min+50 XP

What is a Branch?

A branch is a lightweight, movable pointer to a specific commit. Branching lets you diverge from the main codebase, work in complete isolation, and merge back when ready. Creating a branch costs almost nothing.

01.Why Branches Matter

Without branches, every developer would edit the same codebase simultaneously causing constant conflicts and broken code. With branches: develop features in isolation, fix bugs without touching in-progress features, experiment freely and discard if needed. Each branch is independent until you choose to merge.

Branch Visualization
featuremainHEAD
main
feature
HEAD

02.The HEAD Pointer

HEAD is a special pointer that always marks your current position in the repository — the commit your next change will be built upon. Usually HEAD points to a branch name. When you commit, HEAD and the branch pointer both move forward to the new commit together.

Commit Timeline
a1b2c3d
init
b2c3d4e
feat
c3d4e5f
fix
d4e5f6a
HEAD

Commands

commands — click to reveal output
$
git branch
List all local branches (* marks current)
▼ show output
$
git branch -a
List local AND remote-tracking branches
▼ show output
$
git log --oneline --graph --all
Visualize the entire branch structure
▼ show output
KNOWLEDGE CHECK

What is a Git branch technically?

Rate this lesson:
PreviousNext Lesson