简体   繁体   中英

Retrieve all clone URLs for git repository from command line

I found reliable way of getting my local git URL in post How can I determine the url that a local git repo was originally cloned from?

But how to get all the clone URLs that are available for repository? For example on Github it would be HTTPS, SSH and SVN:

克隆URL github

Of course, I could get my local URL, parse it (based on the protocol) and create the remaining 2 URLs following the respective patterns. But is there really no git command for this? Or even better, be able to choose URL by protocol?

But how to get all the clone URLs that are available for repository?

You can't: it is up to each git hosting server to propose or not different protocol, but there is no command that could "list" those protocols.
And that wouldn't linked to git itself: those are listeners (which, in turn, are calling git commands on the server side)

The only git-related command which might give an hint that a given protocol exists is git ls-remote :

git ls-remote https://github.com/user/repo
git ls-remote ssh://git@github.com/user/repo
...

A 403 Access denied could be an indication that the protocol exists (but that you don't have the right credentials).
Any other error should mean the server doesn't know how to interpreted that url at all, and that the protocol is not available.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM