Issue
Within a bash script, what would be the simplest way to verify that a git URL points to a valid git repo and that the script has access to read from it?
Protocols that should be supported are git@
, https://
, and git://
. Curl fails on the git://
protocol.
[email protected]:UserName/Example.git
https://[email protected]/UserName/Example.git
git://github.com/UserName/Example.git
Note: I'm not asking to check to see if a URL is syntactically correct, I need to verify that a repo exists at the URL location entered from within a bash script.
Solution
As seen in this issue, you can use git ls-remote to test your address.
If you need to debug the git calls
set GIT_TRACE=1
. eg:
env GIT_PROXY_COMMAND=myproxy.sh GIT_TRACE=1 git ls-remote https://...
"
git ls-remote
" is the quickest way I know to test communications with a remote repository without actually cloning it. Hence its utility as a test for this issue.
You can see it used for detecting an address issue in "git ls-remote
returns 128 on any repo".
Answered By - VonC