The git has a few commands to list branches which used to show all branch names that already created in the project. So you can use the following expressions to show branches in remote or local repository. Let’s see how it does work.

Before getting started, you have to know what git branch is and how it does work. Also you can learn how to create and delete branches through the highlighted links in this article.

Anyway, the git branch is a new line in the development which take another direction during the stack.

GitHub branch

Our mission in this article to show you, how to list all branches in git also show you the current activated git branch using a few commands.

How to List All Branches in Git for the Local Repository

To do that you have to use the following git command.

git branch

By running this command, it will show you the following result.

git branch

If you look at the above image you will see 4 branches, which are as the following list:

  • design
  • development
  • master
  • new-file

The green highlighted color and the asterisk flag are referring to the current selected branch in the stack. That means when you run any git command, it will be executed and listed under the selected branch.

To see all branches remotely and locally you have to use the flag “-a” which will list the all branches in the project.

git branch -a

Once you run this command the result would be similar to the below image.

Show All Remote and Local Branches

But how to expose the names of the remote branches? in the next section I will show you that. Let’s move forward.

Show Git Branches Remotely

To show all branches remotely you have to use the same command but within a flag “-r” which refers to –remotes.

git branch -r

Or it can be written like the following.

git branch --remotes

These two commands will show you the same result as in the below image.

git show branches remotely

Anyway, I cloned the same repository to another place and pushed a new branch name with some changes, the branch name was “cars”. In the following command I will back to the old git folder to show you the remote branches without download it.

I will run the below command to list all remote branches with hashes and refs.

git ls-remote --head

Or use the same command with only ls-remote.

git ls-remote

The result of two both would be like the below image.

git ls-remote command

Using Git to List All Branches Locally and Remotely

To see all information for the local branch or the remote branch you have to run the following command with -vv falg for the local or -vva for two both remote and local.

git branch -vv


git branch -vva

The result would be like in the below image.

See all details for the branches

Wrapping Up

In this article you understood how to show all branches on the repository by locally and remotely. Also you saw that by examples.