Logo
Published on

Git FAQ: 7 Ways to to List All Branches in Git

Authors
  • avatar
    Name
    Mike Tsamis
    Twitter

Here are 7 different ways to list all branches in Git.

List All Local Branches

To list all local branches, run the following command:

git branch

List All Remote Branches

Here are two commands that list all remote branches:

git branch -r

or

git remote

List Both Local and Remote Branches

To list both local and remote branches, run the following command:

git branch -a

Note that both "git branch -a" and "git branch -r" may not list all the remote branches if you have not executed a "git fetch" beforehand. You can run this command instead if you don't feel like fetching:

git remote show origin

This command will display all of the remote branches, local branches configured for "git pull", and local refs configured for "git push."

You can also list all local branches paired with their respective remote branches with this command:

git branch -vv

List All Branches and their Commits

To list all branches and their latest commits, run the following command:

git show-branch

Similar to the previous commands, you can add -r to show branches and commits to remote branches and -a to show branches and commits to both remote and local branches.

TL;DR

git branch
git branch -r
git branch -a
git branch -vv
git remote
git remote show origin
git show-branch

Related Articles