Given HTTPs URL of git repository, is it possible to retrieve the SSH url?

后端 未结 1 509
无人共我
无人共我 2021-01-16 14:52

In a Git Repo, if i have the information of the HTTPs protocol saved, is it possible to retrieve the SSH url of it without having to manually login and copy ?

相关标签:
1条回答
  • 2021-01-16 15:30

    In the general case, no, this is not possible. Git does not require that a repository be accessible by multiple methods and does not provide a way to automatically discover all URLs for a repository, even if a repository is accessible by multiple methods. The user must intrinsically know this, and can map from one to the other by using config options of the form url.*.insteadOf if a particular protocol is unsuitable (see git-config(1)).

    For GitHub specifically, yes, it is. A repository that has the HTTPS URL of https://github.com/foo/bar.git will also be accessible at git@github.com:foo/bar.git or ssh://git@github.com/foo/bar.git (among others). This is not necessarily true for GitHub Enterprise Server instances because administrators may restrict the protocols that are used. It is also not true for Subversion access, which is only over HTTPS.

    0 讨论(0)
提交回复
热议问题