Reputation: 941
I need a quick way to understand whether the repo, I am in, is cloned via HTTP or ssh? Looking for a command from Git or any other configuration checkpoint to provide this info for me.
Upvotes: 18
Views: 17011
Reputation: 59913
This command will show you the URLs that the repo will fetch from and push to by default1:
git remote show origin
From the documentation:
In general, URLs contain information about the transport protocol, the address of the remote server, and the path to the repository. Depending on the transport protocol, some of this information may be absent.
Git supports ssh, git, http, and https protocols (in addition, ftp, and ftps can be used for fetching, but this is inefficient and deprecated; do not use it).
While it's not a guarantee that it's where the repository was cloned from in the first place (since you can easily change the URL associated with a remote by using the --set-url
option of git remote
), it's a pretty safe bet in most cases.
git fetch
or git push
without specifying the name of a remote.Upvotes: 18