Git Branches and Commits Explained

People treat commits like saves and branches like scary parallel universes. Both are simpler than that: a commit is a snapshot, a branch is a sticky note pointing at one. Here's the real model.

BytExplorer 6 min read July 1, 2026

Git feels intimidating because the words sound heavier than the ideas. "Commit," "branch," "merge" — they suggest complex machinery. Underneath, Git is built on two simple objects, and once you see them clearly, most of the tool stops being mysterious.

A commit is a snapshot, not a diff

When you git commit, Git saves a snapshot of your whole project at that moment — plus a pointer to the commit that came before it. String those together and you get history: a chain of snapshots, each knowing its parent. A commit isn't "the changes you made"; it's "how everything looked" after you made them.

git add .                       # choose what goes in the snapshot
git commit -m "Add login form"  # freeze it, linked to the previous commit

A branch is just a movable pointer

Here's the part that unlocks everything: a branch is not a copy of your code. It's a lightweight, movable label pointing at one commit. main is just a sticky note that says "the latest commit on the main line is this one." Make a new commit and the note slides forward to it.

A commit is a photo. A branch is a sticky note stuck to one photo that you can peel off and move. Creating a branch doesn't duplicate anything — it just adds another note.

Why branching is cheap

Because a branch is only a pointer, making one is instant and nearly free — no files are copied. That's why Git encourages a branch per feature: you spin off a new pointer, pile up commits on it without touching main, and throw it away or merge it later.

git switch -c feature/login   # new pointer, starts where you are
# ...commit freely here; main is untouched...

What merging really does

Merging takes the commits from one branch and brings them into another, then moves the pointer forward. If both branches changed the same lines, Git pauses and asks you to resolve the overlap — that's a merge conflict, and it just means "two snapshots disagree here, you decide."

The mental model to keep

History is a chain of snapshots. Branches are cheap sticky notes pointing into that chain, and HEAD is the note telling you which one you're standing on. Hold that picture and switching, branching, and merging stop feeling risky — you're just moving labels around a timeline of photos.

Put it into practice

Stop reading, start building

This pairs with a hands-on BytExplorer course — do it on your own machine and actually keep the skill.

More in Core Concepts