1

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:

clone 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?

Community
  • 1
  • 1
lp1051
  • 491
  • 7
  • 19

1 Answers1

0

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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Yes, that is the reason for my question. I used example for Github, but I'm looking for cross-platform git command, if there is any. I thought if I can list all remote branches via `git branch -r`, there could be similar command for the clone URLs. – lp1051 Sep 09 '14 at 09:13
  • @lp1051 no there is not: this isn't a git issue, which explains the lack of git commands. – VonC Sep 09 '14 at 09:14
  • ok, thanks a lot for prompt answers:) If no one will come with some other opinions, I will accept the truth and choose your answer. And perhaps create feature request for git... – lp1051 Sep 09 '14 at 09:26
  • @lp1051 you could try and probe an url with `git ls-remote anurl`: see my edited answer. – VonC Sep 09 '14 at 09:36
  • yes, that would be for the URL verification, but I would still need the logic for constructing the remote git url based on my local one. – lp1051 Sep 09 '14 at 09:42
  • @lp1051 that depends on how the server chose to interpret the url: there is no one standard rule. – VonC Sep 09 '14 at 09:44