Junio C Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 1 | GIT URLS[[URLS]] |
| 2 | ---------------- |
| 3 | |
Junio C Hamano | 0c053e8 | 2010-04-19 06:46:34 | [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. |
Junio C Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 8 | |
Junio C Hamano | 6631a09 | 2012-10-10 22:50:57 | [diff] [blame] | 9 | Git supports ssh, git, http, and https protocols (in addition, ftp, |
| 10 | and ftps can be used for fetching and rsync can be used for fetching |
| 11 | and pushing, but these are inefficient and deprecated; do not use |
| 12 | them). |
| 13 | |
| 14 | The following syntaxes may be used with them: |
Junio C Hamano | 0c053e8 | 2010-04-19 06:46:34 | [diff] [blame] | 15 | |
Junio C Hamano | dbb6459 | 2007-09-01 11:17:39 | [diff] [blame] | 16 | - ssh://{startsb}user@{endsb}host.xz{startsb}:port{endsb}/path/to/repo.git/ |
Junio C Hamano | 0c053e8 | 2010-04-19 06:46:34 | [diff] [blame] | 17 | - git://host.xz{startsb}:port{endsb}/path/to/repo.git/ |
| 18 | - http{startsb}s{endsb}://host.xz{startsb}:port{endsb}/path/to/repo.git/ |
| 19 | - ftp{startsb}s{endsb}://host.xz{startsb}:port{endsb}/path/to/repo.git/ |
| 20 | - rsync://host.xz/path/to/repo.git/ |
Junio C Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 21 | |
Junio C Hamano | 0c053e8 | 2010-04-19 06:46:34 | [diff] [blame] | 22 | An alternative scp-like syntax may also be used with the ssh protocol: |
Junio C Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 23 | |
Junio C Hamano | 0c053e8 | 2010-04-19 06:46:34 | [diff] [blame] | 24 | - {startsb}user@{endsb}host.xz:path/to/repo.git/ |
Junio C Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 25 | |
Junio C Hamano | 7e590a1 | 2013-06-02 23:46:52 | [diff] [blame] | 26 | This syntax is only recognized if there are no slashes before the |
| 27 | first colon. This helps differentiate a local path that contains a |
| 28 | colon. For example the local path `foo:bar` could be specified as an |
| 29 | absolute path or `./foo:bar` to avoid being misinterpreted as an ssh |
| 30 | url. |
| 31 | |
Junio C Hamano | 0c053e8 | 2010-04-19 06:46:34 | [diff] [blame] | 32 | The ssh and git protocols additionally support ~username expansion: |
| 33 | |
| 34 | - ssh://{startsb}user@{endsb}host.xz{startsb}:port{endsb}/~{startsb}user{endsb}/path/to/repo.git/ |
| 35 | - git://host.xz{startsb}:port{endsb}/~{startsb}user{endsb}/path/to/repo.git/ |
| 36 | - {startsb}user@{endsb}host.xz:/~{startsb}user{endsb}/path/to/repo.git/ |
| 37 | |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 38 | For local repositories, also supported by Git natively, the following |
Junio C Hamano | 0c053e8 | 2010-04-19 06:46:34 | [diff] [blame] | 39 | syntaxes may be used: |
Junio C Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 40 | |
Junio C Hamano | 40f2f8d | 2006-02-07 08:04:39 | [diff] [blame] | 41 | - /path/to/repo.git/ |
Junio C Hamano | dc8f8de | 2013-06-05 22:58:07 | [diff] [blame] | 42 | - \file:///path/to/repo.git/ |
Junio C Hamano | b1d6e88 | 2007-08-11 08:30:16 | [diff] [blame] | 43 | |
Junio C Hamano | 63777e2 | 2007-11-17 20:52:16 | [diff] [blame] | 44 | ifndef::git-clone[] |
Junio C Hamano | 0c053e8 | 2010-04-19 06:46:34 | [diff] [blame] | 45 | These two syntaxes are mostly equivalent, except when cloning, when |
| 46 | the former implies --local option. See linkgit:git-clone[1] for |
| 47 | details. |
Junio C Hamano | 63777e2 | 2007-11-17 20:52:16 | [diff] [blame] | 48 | endif::git-clone[] |
| 49 | |
| 50 | ifdef::git-clone[] |
Junio C Hamano | 0c053e8 | 2010-04-19 06:46:34 | [diff] [blame] | 51 | These two syntaxes are mostly equivalent, except the former implies |
| 52 | --local option. |
Junio C Hamano | 63777e2 | 2007-11-17 20:52:16 | [diff] [blame] | 53 | endif::git-clone[] |
Junio C Hamano | 24bc09a | 2008-02-28 00:27:44 | [diff] [blame] | 54 | |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 55 | When Git doesn't know how to handle a certain transport protocol, it |
Junio C Hamano | 0c053e8 | 2010-04-19 06:46:34 | [diff] [blame] | 56 | attempts to use the 'remote-<transport>' remote helper, if one |
| 57 | exists. To explicitly request a remote helper, the following syntax |
| 58 | may be used: |
| 59 | |
| 60 | - <transport>::<address> |
| 61 | |
| 62 | where <address> may be a path, a server and path, or an arbitrary |
| 63 | URL-like string recognized by the specific remote helper being |
Junio C Hamano | b5e079f | 2013-02-08 00:02:52 | [diff] [blame] | 64 | invoked. See linkgit:gitremote-helpers[1] for details. |
Junio C Hamano | 24bc09a | 2008-02-28 00:27:44 | [diff] [blame] | 65 | |
| 66 | If there are a large number of similarly-named remote repositories and |
| 67 | you want to use a different format for them (such that the URLs you |
| 68 | use will be rewritten into URLs that work), you can create a |
| 69 | configuration section of the form: |
| 70 | |
| 71 | ------------ |
| 72 | [url "<actual url base>"] |
| 73 | insteadOf = <other url base> |
| 74 | ------------ |
| 75 | |
| 76 | For example, with this: |
| 77 | |
| 78 | ------------ |
| 79 | [url "git://git.host.xz/"] |
| 80 | insteadOf = host.xz:/path/to/ |
| 81 | insteadOf = work: |
| 82 | ------------ |
| 83 | |
| 84 | a URL like "work:repo.git" or like "host.xz:/path/to/repo.git" will be |
| 85 | rewritten in any context that takes a URL to be "git://git.host.xz/repo.git". |
| 86 | |
Junio C Hamano | 7df6dcf | 2009-09-13 09:51:17 | [diff] [blame] | 87 | If you want to rewrite URLs for push only, you can create a |
| 88 | configuration section of the form: |
| 89 | |
| 90 | ------------ |
| 91 | [url "<actual url base>"] |
| 92 | pushInsteadOf = <other url base> |
| 93 | ------------ |
| 94 | |
| 95 | For example, with this: |
| 96 | |
| 97 | ------------ |
| 98 | [url "ssh://example.org/"] |
| 99 | pushInsteadOf = git://example.org/ |
| 100 | ------------ |
| 101 | |
| 102 | a URL like "git://example.org/path/to/repo.git" will be rewritten to |
| 103 | "ssh://example.org/path/to/repo.git" for pushes, but pulls will still |
| 104 | use the original URL. |