blob: 4e79c1589ece05ff21a144e5b48829a5dc39b50f [file] [log] [blame]
J. Bruce Fields85a97d42006-02-05 18:29:49 -05001GIT URLS[[URLS]]
2----------------
3
Ramkumar Ramachandra5ce4f4e2010-04-06 14:08:19 +05304In general, URLs contain information about the transport protocol, the
5address of the remote server, and the path to the repository.
6Depending on the transport protocol, some of this information may be
7absent.
J. Bruce Fields85a97d42006-02-05 18:29:49 -05008
Elijah Newrencf6cac22023-10-08 06:45:03 +00009Git supports ssh, git, http, and https protocols (in addition, ftp
Jeff King0d0bac62016-01-30 02:21:26 -050010and ftps can be used for fetching, but this is inefficient and
Elijah Newrencf6cac22023-10-08 06:45:03 +000011deprecated; do not use them).
Ramkumar Ramachandra6347e712012-10-08 10:26:53 -070012
Fraser Tweedale20618012013-06-26 15:53:59 +100013The native transport (i.e. git:// URL) does no authentication and
14should be used with caution on unsecured networks.
15
Ramkumar Ramachandra6347e712012-10-08 10:26:53 -070016The following syntaxes may be used with them:
Ramkumar Ramachandra5ce4f4e2010-04-06 14:08:19 +053017
Luben Tuikov2e776662007-09-01 02:36:31 -070018- ssh://{startsb}user@{endsb}host.xz{startsb}:port{endsb}/path/to/repo.git/
Ramkumar Ramachandra5ce4f4e2010-04-06 14:08:19 +053019- git://host.xz{startsb}:port{endsb}/path/to/repo.git/
20- http{startsb}s{endsb}://host.xz{startsb}:port{endsb}/path/to/repo.git/
21- ftp{startsb}s{endsb}://host.xz{startsb}:port{endsb}/path/to/repo.git/
J. Bruce Fields85a97d42006-02-05 18:29:49 -050022
Ramkumar Ramachandra5ce4f4e2010-04-06 14:08:19 +053023An alternative scp-like syntax may also be used with the ssh protocol:
J. Bruce Fields85a97d42006-02-05 18:29:49 -050024
Ramkumar Ramachandra5ce4f4e2010-04-06 14:08:19 +053025- {startsb}user@{endsb}host.xz:path/to/repo.git/
J. Bruce Fields85a97d42006-02-05 18:29:49 -050026
Nguyễn Thái Ngọc Duy60003342013-05-04 09:19:33 +070027This syntax is only recognized if there are no slashes before the
28first colon. This helps differentiate a local path that contains a
29colon. For example the local path `foo:bar` could be specified as an
30absolute path or `./foo:bar` to avoid being misinterpreted as an ssh
31url.
32
Ramkumar Ramachandra5ce4f4e2010-04-06 14:08:19 +053033The ssh and git protocols additionally support ~username expansion:
34
35- ssh://{startsb}user@{endsb}host.xz{startsb}:port{endsb}/~{startsb}user{endsb}/path/to/repo.git/
36- git://host.xz{startsb}:port{endsb}/~{startsb}user{endsb}/path/to/repo.git/
37- {startsb}user@{endsb}host.xz:/~{startsb}user{endsb}/path/to/repo.git/
38
Thomas Ackermann2de9b712013-01-21 20:17:53 +010039For local repositories, also supported by Git natively, the following
Ramkumar Ramachandra5ce4f4e2010-04-06 14:08:19 +053040syntaxes may be used:
J. Bruce Fields85a97d42006-02-05 18:29:49 -050041
J. Bruce Fields3598a302006-02-05 17:43:47 -050042- /path/to/repo.git/
Nguyễn Thái Ngọc Duy4c32e362013-05-24 22:44:03 +070043- \file:///path/to/repo.git/
Junio C Hamano3d5c4182007-08-01 23:42:36 -070044
Sergei Organov347989f2007-11-16 21:43:16 +030045ifndef::git-clone[]
Ramkumar Ramachandra5ce4f4e2010-04-06 14:08:19 +053046These two syntaxes are mostly equivalent, except when cloning, when
47the former implies --local option. See linkgit:git-clone[1] for
48details.
Sergei Organov347989f2007-11-16 21:43:16 +030049endif::git-clone[]
50
51ifdef::git-clone[]
Ramkumar Ramachandra5ce4f4e2010-04-06 14:08:19 +053052These two syntaxes are mostly equivalent, except the former implies
53--local option.
Sergei Organov347989f2007-11-16 21:43:16 +030054endif::git-clone[]
Daniel Barkalow55029ae2008-02-20 13:43:53 -050055
Philip Oakley0e40a732019-10-20 12:03:06 +010056'git clone', 'git fetch' and 'git pull', but not 'git push', will also
57accept a suitable bundle file. See linkgit:git-bundle[1].
58
Thomas Ackermann2de9b712013-01-21 20:17:53 +010059When Git doesn't know how to handle a certain transport protocol, it
Ramkumar Ramachandra5ce4f4e2010-04-06 14:08:19 +053060attempts to use the 'remote-<transport>' remote helper, if one
61exists. To explicitly request a remote helper, the following syntax
62may be used:
63
64- <transport>::<address>
65
66where <address> may be a path, a server and path, or an arbitrary
67URL-like string recognized by the specific remote helper being
Johannes Schindelin439cc742019-03-25 14:41:36 -070068invoked. See linkgit:gitremote-helpers[7] for details.
Daniel Barkalow55029ae2008-02-20 13:43:53 -050069
70If there are a large number of similarly-named remote repositories and
71you want to use a different format for them (such that the URLs you
72use will be rewritten into URLs that work), you can create a
73configuration section of the form:
74
75------------
76 [url "<actual url base>"]
77 insteadOf = <other url base>
78------------
79
80For example, with this:
81
82------------
83 [url "git://git.host.xz/"]
84 insteadOf = host.xz:/path/to/
85 insteadOf = work:
86------------
87
88a URL like "work:repo.git" or like "host.xz:/path/to/repo.git" will be
89rewritten in any context that takes a URL to be "git://git.host.xz/repo.git".
90
Josh Triplett1c2eafb2009-09-07 01:56:33 -070091If you want to rewrite URLs for push only, you can create a
92configuration section of the form:
93
94------------
95 [url "<actual url base>"]
96 pushInsteadOf = <other url base>
97------------
98
99For example, with this:
100
101------------
102 [url "ssh://example.org/"]
103 pushInsteadOf = git://example.org/
104------------
105
106a URL like "git://example.org/path/to/repo.git" will be rewritten to
107"ssh://example.org/path/to/repo.git" for pushes, but pulls will still
108use the original URL.