Branching mental model
A branch is a movable label that points to a commit. When you commit on a branch, the label moves forward. Branches are cheap, fast, and central to safe Git work.
git branch
git log --oneline --decorate --graph --allThe current branch is the one that receives new commits. Git stores this through HEAD, which usually points at a branch name.
Why branches help
- Keep unfinished work away from the stable branch.
- Try multiple ideas independently.
- Prepare focused pull requests for review.
- Make rollback easier when an experiment fails.
Think of main as the shared stable line. Create a feature branch when you start a change, commit there, and merge it back when the work is reviewed and ready.