🌿 BranchingCommonly used

How to list branches in Git

View all local and remote branches in your repository.

List local branches
git branch

Shows all local branches. The current branch is marked with *.

List all branches including remote
git branch -a

Shows all local and remote branches.

List remote branches only
git branch -r

Shows only remote tracking branches.

List branches with last commit
git branch -v

Shows each branch with its last commit hash and message.

When to use: Useful to see which branches are up to date.

List merged branches
git branch --merged main

Shows branches that have already been merged into main. Safe to delete these.

When to use: Finding branches you can safely clean up.

← Back to Git Reference