J. Bruce Fields | 85a97d4 | 2006-02-05 18:29:49 -0500 | [diff] [blame] | 1 | GIT URLS[[URLS]] |
| 2 | ---------------- |
| 3 | |
Ramkumar Ramachandra | 5ce4f4e | 2010-04-06 14:08:19 +0530 | [diff] [blame] | 4 | In general, URLs contain information about the transport protocol, the |
| 5 | address of the remote server, and the path to the repository. |
| 6 | Depending on the transport protocol, some of this information may be |
| 7 | absent. |
J. Bruce Fields | 85a97d4 | 2006-02-05 18:29:49 -0500 | [diff] [blame] | 8 | |
Elijah Newren | cf6cac2 | 2023-10-08 06:45:03 +0000 | [diff] [blame] | 9 | Git supports ssh, git, http, and https protocols (in addition, ftp |
Jeff King | 0d0bac6 | 2016-01-30 02:21:26 -0500 | [diff] [blame] | 10 | and ftps can be used for fetching, but this is inefficient and |
Elijah Newren | cf6cac2 | 2023-10-08 06:45:03 +0000 | [diff] [blame] | 11 | deprecated; do not use them). |
Ramkumar Ramachandra | 6347e71 | 2012-10-08 10:26:53 -0700 | [diff] [blame] | 12 | |
Fraser Tweedale | 2061801 | 2013-06-26 15:53:59 +1000 | [diff] [blame] | 13 | The native transport (i.e. git:// URL) does no authentication and |
| 14 | should be used with caution on unsecured networks. |
| 15 | |
Ramkumar Ramachandra | 6347e71 | 2012-10-08 10:26:53 -0700 | [diff] [blame] | 16 | The following syntaxes may be used with them: |
Ramkumar Ramachandra | 5ce4f4e | 2010-04-06 14:08:19 +0530 | [diff] [blame] | 17 | |
Luben Tuikov | 2e77666 | 2007-09-01 02:36:31 -0700 | [diff] [blame] | 18 | - ssh://{startsb}user@{endsb}host.xz{startsb}:port{endsb}/path/to/repo.git/ |
Ramkumar Ramachandra | 5ce4f4e | 2010-04-06 14:08:19 +0530 | [diff] [blame] | 19 | - 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 Fields | 85a97d4 | 2006-02-05 18:29:49 -0500 | [diff] [blame] | 22 | |
Ramkumar Ramachandra | 5ce4f4e | 2010-04-06 14:08:19 +0530 | [diff] [blame] | 23 | An alternative scp-like syntax may also be used with the ssh protocol: |
J. Bruce Fields | 85a97d4 | 2006-02-05 18:29:49 -0500 | [diff] [blame] | 24 | |
Ramkumar Ramachandra | 5ce4f4e | 2010-04-06 14:08:19 +0530 | [diff] [blame] | 25 | - {startsb}user@{endsb}host.xz:path/to/repo.git/ |
J. Bruce Fields | 85a97d4 | 2006-02-05 18:29:49 -0500 | [diff] [blame] | 26 | |
Nguyễn Thái Ngọc Duy | 6000334 | 2013-05-04 09:19:33 +0700 | [diff] [blame] | 27 | This syntax is only recognized if there are no slashes before the |
| 28 | first colon. This helps differentiate a local path that contains a |
| 29 | colon. For example the local path `foo:bar` could be specified as an |
| 30 | absolute path or `./foo:bar` to avoid being misinterpreted as an ssh |
| 31 | url. |
| 32 | |
Ramkumar Ramachandra | 5ce4f4e | 2010-04-06 14:08:19 +0530 | [diff] [blame] | 33 | The 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 Ackermann | 2de9b71 | 2013-01-21 20:17:53 +0100 | [diff] [blame] | 39 | For local repositories, also supported by Git natively, the following |
Ramkumar Ramachandra | 5ce4f4e | 2010-04-06 14:08:19 +0530 | [diff] [blame] | 40 | syntaxes may be used: |
J. Bruce Fields | 85a97d4 | 2006-02-05 18:29:49 -0500 | [diff] [blame] | 41 | |
J. Bruce Fields | 3598a30 | 2006-02-05 17:43:47 -0500 | [diff] [blame] | 42 | - /path/to/repo.git/ |
Nguyễn Thái Ngọc Duy | 4c32e36 | 2013-05-24 22:44:03 +0700 | [diff] [blame] | 43 | - \file:///path/to/repo.git/ |
Junio C Hamano | 3d5c418 | 2007-08-01 23:42:36 -0700 | [diff] [blame] | 44 | |
Sergei Organov | 347989f | 2007-11-16 21:43:16 +0300 | [diff] [blame] | 45 | ifndef::git-clone[] |
Ramkumar Ramachandra | 5ce4f4e | 2010-04-06 14:08:19 +0530 | [diff] [blame] | 46 | These two syntaxes are mostly equivalent, except when cloning, when |
| 47 | the former implies --local option. See linkgit:git-clone[1] for |
| 48 | details. |
Sergei Organov | 347989f | 2007-11-16 21:43:16 +0300 | [diff] [blame] | 49 | endif::git-clone[] |
| 50 | |
| 51 | ifdef::git-clone[] |
Ramkumar Ramachandra | 5ce4f4e | 2010-04-06 14:08:19 +0530 | [diff] [blame] | 52 | These two syntaxes are mostly equivalent, except the former implies |
| 53 | --local option. |
Sergei Organov | 347989f | 2007-11-16 21:43:16 +0300 | [diff] [blame] | 54 | endif::git-clone[] |
Daniel Barkalow | 55029ae | 2008-02-20 13:43:53 -0500 | [diff] [blame] | 55 | |
Philip Oakley | 0e40a73 | 2019-10-20 12:03:06 +0100 | [diff] [blame] | 56 | 'git clone', 'git fetch' and 'git pull', but not 'git push', will also |
| 57 | accept a suitable bundle file. See linkgit:git-bundle[1]. |
| 58 | |
Thomas Ackermann | 2de9b71 | 2013-01-21 20:17:53 +0100 | [diff] [blame] | 59 | When Git doesn't know how to handle a certain transport protocol, it |
Ramkumar Ramachandra | 5ce4f4e | 2010-04-06 14:08:19 +0530 | [diff] [blame] | 60 | attempts to use the 'remote-<transport>' remote helper, if one |
| 61 | exists. To explicitly request a remote helper, the following syntax |
| 62 | may be used: |
| 63 | |
| 64 | - <transport>::<address> |
| 65 | |
| 66 | where <address> may be a path, a server and path, or an arbitrary |
| 67 | URL-like string recognized by the specific remote helper being |
Johannes Schindelin | 439cc74 | 2019-03-25 14:41:36 -0700 | [diff] [blame] | 68 | invoked. See linkgit:gitremote-helpers[7] for details. |
Daniel Barkalow | 55029ae | 2008-02-20 13:43:53 -0500 | [diff] [blame] | 69 | |
| 70 | If there are a large number of similarly-named remote repositories and |
| 71 | you want to use a different format for them (such that the URLs you |
| 72 | use will be rewritten into URLs that work), you can create a |
| 73 | configuration section of the form: |
| 74 | |
| 75 | ------------ |
| 76 | [url "<actual url base>"] |
| 77 | insteadOf = <other url base> |
| 78 | ------------ |
| 79 | |
| 80 | For example, with this: |
| 81 | |
| 82 | ------------ |
| 83 | [url "git://git.host.xz/"] |
| 84 | insteadOf = host.xz:/path/to/ |
| 85 | insteadOf = work: |
| 86 | ------------ |
| 87 | |
| 88 | a URL like "work:repo.git" or like "host.xz:/path/to/repo.git" will be |
| 89 | rewritten in any context that takes a URL to be "git://git.host.xz/repo.git". |
| 90 | |
Josh Triplett | 1c2eafb | 2009-09-07 01:56:33 -0700 | [diff] [blame] | 91 | If you want to rewrite URLs for push only, you can create a |
| 92 | configuration section of the form: |
| 93 | |
| 94 | ------------ |
| 95 | [url "<actual url base>"] |
| 96 | pushInsteadOf = <other url base> |
| 97 | ------------ |
| 98 | |
| 99 | For example, with this: |
| 100 | |
| 101 | ------------ |
| 102 | [url "ssh://example.org/"] |
| 103 | pushInsteadOf = git://example.org/ |
| 104 | ------------ |
| 105 | |
| 106 | a 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 |
| 108 | use the original URL. |