Domdhi logoDOMDHI.OS
BACK_TO_COURSE

Branching Without Fear

Branches Are Just Pointers

The Scariest-Looking Feature Is Actually the Cheapest

A branch is not a copy of your project. It's a lightweight, movable pointer to a single commit. HEAD is just a pointer to "whichever branch (or commit) you currently have checked out." That's it. That's the entire mental model.

Because a branch is just a pointer, creating one is instant regardless of project size — git isn't copying any files.

git branch feature-x        # create a pointer called feature-x at the current commit
git switch feature-x         # move HEAD to point at feature-x
git switch -c feature-y      # create + switch in one step
git branch -d feature-x      # delete the pointer (safe — only if merged)

Why Teams Branch at All

Branching lets multiple lines of work exist without interfering with each other, and lets main stay in a known-good, deployable state while work-in-progress happens elsewhere.

TIP

git switch and git restore are the modern, less-confusing replacements for the overloaded git checkout (which historically did both "switch branches" and "discard file changes" — two very different levels of danger under one command name).

QUIZ

What is a git branch, technically?

Sign in to track lesson progress and earn a certificate.SIGN IN TO SAVE PROGRESS