Vasu Patel logoVasu Patel
← Git Mastery
All chapters in this track
  1. 011. The Mental Model
  2. 022. Essential Setup
  3. 033. Core Daily Workflow
  4. 044. Branching
  5. 055. Merging & Conflict Resolution
  6. 066. Rebasing
  7. 077. Remote Repositories
  8. 088. Stashing
  9. 099. Undoing Things
  10. 1010. Tagging & Versioning
  11. 1111. Cherry-Pick
  12. 1212. Git Bisect & Blame
  13. 1313. Git Hooks
  14. 1414. Submodules
  15. 1515. Team Workflows
  16. 1616. Power Commands & Aliases
  17. 1717. Reflog: The Safety Net
  18. 1818. Practice Tasks
  19. 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

PatternExample
Featurefeature/user-auth
Bug fixfix/null-pointer-cart
Hotfixhotfix/v2.1.1-payment
Releaserelease/2.1.0