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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With