Git Branching allows developers to work on multiple features, bug fixes, or experiments in parallel without disturbing the main codebase.
A Git branch is a lightweight pointer to a commit. Branches allow independent development and easy integration.
# Lists all local branches
git branch
# Creates a new branch
git branch feature-xyz
# Switches to an existing branch
git checkout feature-xyz
# Creates and switches to a new branch
git checkout -b feature-xyz
# Merge feature branch into main
git checkout main
git merge feature-xyz
# Deletes a merged branch
git branch -d feature-xyz
# Lists remote branches
git branch -r