15

I want to get all branch names of a git repository. Currently, I clone the repository then get them on local machine. This is inefficient because all I need is names and nothing else.

I wonder if it is possible to do that? If so, what command I can use.

Anonymous
  • 9,366
  • 22
  • 83
  • 133
  • As long as you have access to the remote repository in question you can take a look in the `refs/heads` folder which you can find in your remote repository. The files in there are effectively the branches of the repository. – Sascha Wolf Sep 10 '14 at 12:17
  • @Zeeker This requires shell access which is almost always disabled for git users. – musiKk Sep 10 '14 at 12:44

1 Answers1

21

Locally, without cloning, you can type (using git ls-remote):

git ls-remote /url/of/the/upstream/repo

That will list of the remote HEADS and their associated branches

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Why does that command return two tags `refs/tags/TAG` and `refs/tags/TAG^{}` despite the fact that I only have one? – Anonymous Sep 11 '14 at 03:01
  • I found the answer here: http://stackoverflow.com/questions/12938972/what-does-mean-in-git. Thank you for your help! – Anonymous Sep 11 '14 at 03:26