All chapters in this track
- 011. The Mental Model
- 022. Essential Setup
- 033. Core Daily Workflow
- 044. Branching
- 055. Merging & Conflict Resolution
- 066. Rebasing
- 077. Remote Repositories
- 088. Stashing
- 099. Undoing Things
- 1010. Tagging & Versioning
- 1111. Cherry-Pick
- 1212. Git Bisect & Blame
- 1313. Git Hooks
- 1414. Submodules
- 1515. Team Workflows
- 1616. Power Commands & Aliases
- 1717. Reflog: The Safety Net
- 1818. Practice Tasks
- 19Quick Reference Cheatsheet
Chapter 4 of 19
4. Branching
Branches are cheap pointers to commits — creating one is instant.
# Create and switch
git branch feature/login # create
git switch feature/login # switch (preferred over checkout)
git switch -c feature/login # create + switch in one step
# List
git branch # local branches
git branch -a # local + remote
git branch -v # with last commit
# Delete
git branch -d feature/login # safe delete (won't delete unmerged)
git branch -D feature/login # force delete
# Rename
git branch -m old-name new-name
# See which branches are merged into main
git branch --merged main
git branch --no-merged main
Branch naming conventions
| Pattern | Example |
|---|---|
| Feature | feature/user-auth |
| Bug fix | fix/null-pointer-cart |
| Hotfix | hotfix/v2.1.1-payment |
| Release | release/2.1.0 |