Git Essentials

Branches in Git

T'Chaka Dev· 9 pages· 6 min read

A branch is an alternative timeline for your code. Not a copy, not a folder — a movable pointer at a commit.

What a branch is

DIAGRAM main line with a branch line splitting off, both pointing at commits, merge point in neon

Because a branch is just a pointer, creating one is instant and costs nothing. This is why git encourages branching where older tools discouraged it.

Creating and switching

bash
git branch feature/kimoyo-sync git switch feature/kimoyo-sync git switch -c feature/another

git checkout does both jobs and more, which is exactly why switch and restore were added.

Merging

bash
git switch main git merge feature/kimoyo-sync

A merge conflict is not an error. It is git telling you that two timelines changed the same lines and only a human can decide which wins.