Home > Enterprise >  How to check if a repository is cloned via HTTP or ssh?
How to check if a repository is cloned via HTTP or ssh?

Time:10-21

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.

CodePudding user response:

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.


  1. Where by "default", I mean if you just do git fetch or git push without specifying the name of a remote.
  • Related