git branch
List, create, rename, or delete branches
Practical example
git branch feature-login # create branch at current commit git branch -d feature-login # delete after merging git branch -a # list all local and remote branches
Command overview & how it works
A branch is a lightweight, movable pointer to a specific commit. Use git branch without arguments to list all local branches — the current branch is highlighted with an asterisk. Create a new branch with git branch <name>, which creates a pointer at the current commit without switching to it. Use git branch -d <name> to delete a merged branch safely, or git branch -D to force-delete an unmerged branch. Rename a branch with git branch -m <old> <new>. List remote branches with git branch -r, and all branches (local + remote) with git branch -a. The git branch -vv command shows which remote branch each local branch is tracking. Branch names should be descriptive and use hyphens as separators — like feature-login or hotfix-security-patch.
Resolve conflicts and master branch mechanics
Understand 3-way diffs, conflict marker anatomy, and rebasing playbooks in the 97-page offline course — ₹499.
Practical tips
- Name branches descriptively with hyphens, such as feature/login or hotfix/payment-timeout.
- Use git branch -vv to see which remote branch each local branch tracks.
- Delete merged branches with git branch -d (safe); reserve -D for work you are certain you can lose.
Deep-dive guides & tutorials
In-depth walkthroughs and practical scenarios related to git branch
- Guide
Git Branching Strategies: Git Flow vs Trunk-Based Development
Compare the most popular branching models and learn when to use merge, rebase, and squash for a clean project history.
8 min readRead guide - Guide
Git Rebase vs Merge: When to Use Each
A clear breakdown of the trade-offs between rebasing and merging, with examples of when each approach makes sense.
5 min readRead guide - Guide
Resolving Git Merge Conflicts: A Practical Guide
Conflicts are inevitable. Learn how to read conflict markers, resolve them systematically, and use tools to make merging painless.
6 min readRead guide
Related commands
More from Branching & Merging