Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I check whether I have access to a repository without cloning?

I have some code where people submit git repo links. The repo may be served over HTTPS with no authentication or HTTPS with basic authentication. I want to check programmatically whether if I have access to the repo. I don’t want to run git clone because it could be time-consuming to download the entire history. I’m trying to find the fastest way to test authentication.

like image 448
jas Avatar asked Mar 28 '16 11:03

jas


1 Answers

One route is git ls-remote as in

$ if git ls-remote https://github.com/git/git.git >/dev/null ; then echo got it ; fi
got it
like image 169
Greg Bacon Avatar answered Sep 22 '22 08:09

Greg Bacon