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