Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 695
Naser Nikzad Avatar asked Dec 07 '25 13:12

Naser Nikzad


1 Answers

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.
like image 62
Enrico Campidoglio Avatar answered Dec 10 '25 03:12

Enrico Campidoglio