Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'd like to know whether a remote repository exists. Here's what I came up with:

git ls-remote "$REPO_URL" &> /dev/null

Is there any better way?

share|improve this question
It seems like a fine choice. The overhead of the “extra work” of fetching and formatting the list of refs (which is then sent to /dev/null) should be fairly small. –  Chris Johnsen Dec 31 '10 at 0:57

3 Answers 3

up vote 19 down vote accepted

I think the git ls-remote command is pretty much made for that purpose.

share|improve this answer
Thanks Chris, thanks Peter! –  Jo Liss Jan 2 '11 at 17:43

If you use --exit-code argument you can skip sending output to null. It will return something only in case of error.

Also, you can use -h argument to show only heads references.

git ls-remote --exit-code -h "$REPO_URL"
share|improve this answer

You can narrow output by using something like git ls-remote "$REPO_URL" HEAD

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.