Listing branches from remote repository
You can list all the branches from a remote repository by visiting the “View all branches” link on the repository page in your GitHub account or by issuing the command git branch -a in your git setup in the terminal. You must first do git fetch on the remote repositories from which you want the information.
Let us check with a hands-on example. The GitHub account used for this example is live and available at https://github.com/codeversionmaster.
The online way of listing all the branches
Click on “Your Repositories” link in the profile dropdown in your GitHub account, as shown in the below image. You can also directly visit https://github.com/codeversionmaster?tab=repositories, where codeversionmaster is the account name.

Click on the specific repository. In this example, click on repoone to reach the page as shown in the below image. Alternatively, you can visit the URL directly at https://github.com/codeversionmaster/repoone, where repoone is the branch name, codeversionmaster is the account name.

Check the dropdown in the left top area that shows the primary or master branch. Click the dropdown and click on “View all branches” as shown in the below image.

The branches will be as shown below. You can also directly get to this page by visiting https://github.com/codeversionmaster/repoone/branches.

Using git branch -a to list the branches
The initial setup is as shown. There is a repository with the name origin added by default. It points to repoone repository.
~/repoone$ git remote -v
origin git@github.com:codeversionmaster/repoone.git (fetch)
origin git@github.com:codeversionmaster/repoone.git (push)
If our interest is to list all the branches in repoone, we do a fetch first, followed by git branch -a. The output would be a list of all the branches from origin (pointed to repoone).
~/repoone$ git fetch origin
~/repoone$ git branch -a
* main
remotes/origin/HEAD -> origin/main
remotes/origin/main
remotes/origin/maincopy
If we want to get branches from both repoone and repotwo, we should add repotwo as a remote repository using git remote add. After adding, use git remote -v to check it got added. As you can see, we have added the repo with the name repotwo. It can be named anything locally.
~/repoone$ git remote add repotwo git@github.com:codeversionmaster/repotwo.git
~/repoone$ git remote -v
origin git@github.com:codeversionmaster/repoone.git (fetch)
origin git@github.com:codeversionmaster/repoone.git (push)
repotwo git@github.com:codeversionmaster/repotwo.git (fetch)
repotwo git@github.com:codeversionmaster/repotwo.git (push)
Now, we can do git fetch on repotwo and use git branch -a. This would list all the branches from all the repositories added in the local git setup.
~/repoone$ git fetch repotwo
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 6 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (6/6), 1.23 KiB | 630.00 KiB/s, done.
From github.com:codeversionmaster/repotwo
* [new branch] main -> repotwo/main
~/repoone$ git branch -a
* main
remotes/origin/HEAD -> origin/main
remotes/origin/main
remotes/origin/maincopy
remotes/repotwo/main
Note that git fetch is necessary after adding a remote repository or if the repository had changes directly in the online GitHub account. The local setup would not have the information of new branches or changes in commits done online till you do git fetch.