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.

2
  • 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. Commented Sep 10, 2014 at 12:17
  • @Zeeker This requires shell access which is almost always disabled for git users. Commented Sep 10, 2014 at 12:44

1 Answer 1

22

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

Sign up to request clarification or add additional context in comments.

2 Comments

Why does that command return two tags refs/tags/TAG and refs/tags/TAG^{} despite the fact that I only have one?
I found the answer here: stackoverflow.com/questions/12938972/what-does-mean-in-git. Thank you for your help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.