Branches, when you actually need them
You can go a long way without them. Here's when you can't.
Working alone, committing to one branch is a completely reasonable way to work, and it's simpler. Branches earn their complexity in three specific situations.
When they're worth it
A risky change you might abandon. Rewriting how something works, trying a different library, restructuring. Branch it, and abandoning is one command rather than an unpicking exercise.
Something long-running while you still ship small fixes. A feature that takes two weeks shouldn't block a typo fix going live.
Anything you want reviewed before it lands — by a person, or by yourself with fresh eyes.
Outside those, committing directly is fine and less to think about.
The five commands
git switch -c my-feature # create and switch to a new branch git switch main # go back git merge my-feature # bring the work into main git branch -d my-feature # delete it once merged git branch # what branches exist
Keep them short
The longer a branch lives, the further it drifts from main, and the harder the merge. A branch that lives a day merges cleanly. One that lives three weeks becomes a project of its own.
If a branch is getting long, merge main into it periodically. You resolve conflicts a few at a time rather than all at once at the end.
Conflicts
A conflict means both branches changed the same lines and git won't guess. It marks the file with both versions; you pick, remove the markers, and commit.
I have a merge conflict in <file>. Here's the conflicted section with the markers: <paste> Explain what each side was trying to do, then tell me what the merged version should be and why. If the two changes are genuinely incompatible, say so rather than picking one arbitrarily.
Understand both sides before resolving. Blindly keeping one version silently deletes work — and it'll be the work you don't notice missing until later.
With agents
If you let an agent work on a risky task, a branch is a cheap safety net. git switch -c agent-attempt, let it work, review the diff, and either merge or delete the whole branch. No partial cleanup.
git switch -c on the risky thing costs three seconds and removes the fear that makes people avoid trying things.