Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the supported git url formats?

Tags:

git

github

ssh

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

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/
like image 818
Ionică Bizău Avatar asked Aug 04 '15 05:08

Ionică Bizău


People also ask

What is the URL of my git repository?

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.

What protocols does Git support?

Git can use four distinct protocols to transfer data: Local, HTTP, Secure Shell (SSH) and Git.

What is git remote set URL?

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.

Does GIT use HTTPS?

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


1 Answers

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.

like image 89
VonC Avatar answered Oct 04 '22 21:10

VonC