13

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
  • 8,966
  • 22
  • 82
  • 129
  • 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

20

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,129,465
  • 480
  • 4,036
  • 4,755
  • 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