🌿 BranchingCommonly used
How to list branches in Git
View all local and remote branches in your repository.
List local branches
git branchShows all local branches. The current branch is marked with *.
List all branches including remote
git branch -aShows all local and remote branches.
List remote branches only
git branch -rShows only remote tracking branches.
List branches with last commit
git branch -vShows 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 mainShows branches that have already been merged into main. Safe to delete these.
When to use: Finding branches you can safely clean up.