When working with Git, branches help you manage different lines of development. At times, you’ll want to list all branches available both locally and remotely to get a clear picture of your repository’s structure.
This guide shows you how to easily view all branches in Git.
✅ View Local Branches
To see all branches stored locally on your machine:
git branch
This lists all your local branches and highlights the current branch with an asterisk (*).
✅ View Remote Branches
To list branches available on the remote repository (like GitHub):
git branch -r
This will show remote tracking branches, usually prefixed with origin/.
✅ View All Branches (Local + Remote)
To see both local and remote branches together:
git branch -a
This lists all branches, showing local branches plain and remote branches prefixed with remotes/.
✅ Additional Tips
- Use
git checkout branch-nameorgit switch branch-nameto switch between branches. - To get detailed information on branches and their last commits:
git branch -vv
🧩 Summary of Commands
| Task | Command |
|---|---|
| List local branches | git branch |
| List remote branches | git branch -r |
| List all branches | git branch -a |
| List branches with details | git branch -vv |
📌 Final Thought
Regularly checking branches helps keep your workflow organized, especially when collaborating on large projects with many contributors.