Git accepts a lot of different url formats (e.g. ssh, http, https etc). Are there any specifications/official docs where I can find the supported git url formats?
I wrote a git url parser and I want to be sure that what it's done there is correct.
Here, on YonderGit, I found the list below. It is not complete since https://<token>:[email protected]/path/to/repo.git
is not there.
Secure Shell Transport Protocol
ssh://[email protected]:port/path/to/repo.git/
ssh://[email protected]/path/to/repo.git/
ssh://host.xz:port/path/to/repo.git/
ssh://host.xz/path/to/repo.git/
ssh://[email protected]/path/to/repo.git/
ssh://host.xz/path/to/repo.git/
ssh://[email protected]/~user/path/to/repo.git/
ssh://host.xz/~user/path/to/repo.git/
ssh://[email protected]/~/path/to/repo.git
ssh://host.xz/~/path/to/repo.git
[email protected]:/path/to/repo.git/
host.xz:/path/to/repo.git/
[email protected]:~user/path/to/repo.git/
host.xz:~user/path/to/repo.git/
[email protected]:path/to/repo.git
host.xz:path/to/repo.git
rsync://host.xz/path/to/repo.git/
Git Transport Protocol
git://host.xz/path/to/repo.git/
git://host.xz/~user/path/to/repo.git/
HTTP/S Transport Protocol
http://host.xz/path/to/repo.git/
https://host.xz/path/to/repo.git/
Local (Filesystem) Transport Protocol
/path/to/repo.git/
path/to/repo.git/
~/path/to/repo.git
file:///path/to/repo.git/
file://~/path/to/repo.git/
On the GitHub website, click on you repository of interest. Locate the green button named Code and click on it. The GitHub URL will appear. Copy the GitHub URL.
Git can use four distinct protocols to transfer data: Local, HTTP, Secure Shell (SSH) and Git.
The git remote set-url command changes the Git remote associated with a repository. This command accepts the name of the remote (which is usually “origin”) and the new remote URL to which you want the repository to point.
The default on both GitHub.com (the website) and in GitHub CLI is using the HTTPS protocol for git operations. This default was chosen for interoperability and ease of use: Git users who are behind firewalls find that traffic to port 443 (HTTPS) is more often allowed than traffic to port 22 (SSH).
You can see what git is prepared to parse in urlmatch.h
and urlmatch.c
.
That is used by t0110-urlmatch-normalization.sh
, which illustrates the full list of possible url tested by git.
url.c
does mention:
The set of valid URL schemes, as per STD66 (RFC3986) is '
[A-Za-z][A-Za-z0-9+.-]*
'.
But use sightly looser check of '[A-Za-z0-9][A-Za-z0-9+.-]*
' because earlier version of check used '[A-Za-z0-9]+
' so not to break any remote helpers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With