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

左心房为你撑大大i 提交于 2020-06-08 13:11:05

问题


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:


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.



来源:https://stackoverflow.com/questions/61782767/given-https-url-of-git-repository-is-it-possible-to-retrieve-the-ssh-url

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!