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 | |
Ramkumar Ramachandra | 5ce4f4e | 2010-04-06 14:08:19 +0530 | [diff] [blame] | 9 | Git natively supports ssh, git, http, https, ftp, ftps, and rsync |
| 10 | protocols. The following syntaxes may be used with them: |
| 11 | |
Luben Tuikov | 2e77666 | 2007-09-01 02:36:31 -0700 | [diff] [blame] | 12 | - 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] | 13 | - git://host.xz{startsb}:port{endsb}/path/to/repo.git/ |
| 14 | - http{startsb}s{endsb}://host.xz{startsb}:port{endsb}/path/to/repo.git/ |
| 15 | - ftp{startsb}s{endsb}://host.xz{startsb}:port{endsb}/path/to/repo.git/ |
| 16 | - rsync://host.xz/path/to/repo.git/ |
J. Bruce Fields | 85a97d4 | 2006-02-05 18:29:49 -0500 | [diff] [blame] | 17 | |
Ramkumar Ramachandra | 5ce4f4e | 2010-04-06 14:08:19 +0530 | [diff] [blame] | 18 | 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] | 19 | |
Ramkumar Ramachandra | 5ce4f4e | 2010-04-06 14:08:19 +0530 | [diff] [blame] | 20 | - {startsb}user@{endsb}host.xz:path/to/repo.git/ |
J. Bruce Fields | 85a97d4 | 2006-02-05 18:29:49 -0500 | [diff] [blame] | 21 | |
Ramkumar Ramachandra | 5ce4f4e | 2010-04-06 14:08:19 +0530 | [diff] [blame] | 22 | The ssh and git protocols additionally support ~username expansion: |
| 23 | |
| 24 | - ssh://{startsb}user@{endsb}host.xz{startsb}:port{endsb}/~{startsb}user{endsb}/path/to/repo.git/ |
| 25 | - git://host.xz{startsb}:port{endsb}/~{startsb}user{endsb}/path/to/repo.git/ |
| 26 | - {startsb}user@{endsb}host.xz:/~{startsb}user{endsb}/path/to/repo.git/ |
| 27 | |
Ville Skyttä | 6b677a2 | 2010-07-20 00:17:17 +0300 | [diff] [blame] | 28 | For local repositories, also supported by git natively, the following |
Ramkumar Ramachandra | 5ce4f4e | 2010-04-06 14:08:19 +0530 | [diff] [blame] | 29 | syntaxes may be used: |
J. Bruce Fields | 85a97d4 | 2006-02-05 18:29:49 -0500 | [diff] [blame] | 30 | |
J. Bruce Fields | 3598a30 | 2006-02-05 17:43:47 -0500 | [diff] [blame] | 31 | - /path/to/repo.git/ |
Junio C Hamano | 3d5c418 | 2007-08-01 23:42:36 -0700 | [diff] [blame] | 32 | - file:///path/to/repo.git/ |
Junio C Hamano | 3d5c418 | 2007-08-01 23:42:36 -0700 | [diff] [blame] | 33 | |
Sergei Organov | 347989f | 2007-11-16 21:43:16 +0300 | [diff] [blame] | 34 | ifndef::git-clone[] |
Ramkumar Ramachandra | 5ce4f4e | 2010-04-06 14:08:19 +0530 | [diff] [blame] | 35 | These two syntaxes are mostly equivalent, except when cloning, when |
| 36 | the former implies --local option. See linkgit:git-clone[1] for |
| 37 | details. |
Sergei Organov | 347989f | 2007-11-16 21:43:16 +0300 | [diff] [blame] | 38 | endif::git-clone[] |
| 39 | |
| 40 | ifdef::git-clone[] |
Ramkumar Ramachandra | 5ce4f4e | 2010-04-06 14:08:19 +0530 | [diff] [blame] | 41 | These two syntaxes are mostly equivalent, except the former implies |
| 42 | --local option. |
Sergei Organov | 347989f | 2007-11-16 21:43:16 +0300 | [diff] [blame] | 43 | endif::git-clone[] |
Daniel Barkalow | 55029ae | 2008-02-20 13:43:53 -0500 | [diff] [blame] | 44 | |
Ramkumar Ramachandra | 5ce4f4e | 2010-04-06 14:08:19 +0530 | [diff] [blame] | 45 | When git doesn't know how to handle a certain transport protocol, it |
| 46 | attempts to use the 'remote-<transport>' remote helper, if one |
| 47 | exists. To explicitly request a remote helper, the following syntax |
| 48 | may be used: |
| 49 | |
| 50 | - <transport>::<address> |
| 51 | |
| 52 | where <address> may be a path, a server and path, or an arbitrary |
| 53 | URL-like string recognized by the specific remote helper being |
| 54 | invoked. See linkgit:git-remote-helpers[1] for details. |
Daniel Barkalow | 55029ae | 2008-02-20 13:43:53 -0500 | [diff] [blame] | 55 | |
| 56 | If there are a large number of similarly-named remote repositories and |
| 57 | you want to use a different format for them (such that the URLs you |
| 58 | use will be rewritten into URLs that work), you can create a |
| 59 | configuration section of the form: |
| 60 | |
| 61 | ------------ |
| 62 | [url "<actual url base>"] |
| 63 | insteadOf = <other url base> |
| 64 | ------------ |
| 65 | |
| 66 | For example, with this: |
| 67 | |
| 68 | ------------ |
| 69 | [url "git://git.host.xz/"] |
| 70 | insteadOf = host.xz:/path/to/ |
| 71 | insteadOf = work: |
| 72 | ------------ |
| 73 | |
| 74 | a URL like "work:repo.git" or like "host.xz:/path/to/repo.git" will be |
| 75 | rewritten in any context that takes a URL to be "git://git.host.xz/repo.git". |
| 76 | |
Josh Triplett | 1c2eafb | 2009-09-07 01:56:33 -0700 | [diff] [blame] | 77 | If you want to rewrite URLs for push only, you can create a |
| 78 | configuration section of the form: |
| 79 | |
| 80 | ------------ |
| 81 | [url "<actual url base>"] |
| 82 | pushInsteadOf = <other url base> |
| 83 | ------------ |
| 84 | |
| 85 | For example, with this: |
| 86 | |
| 87 | ------------ |
| 88 | [url "ssh://example.org/"] |
| 89 | pushInsteadOf = git://example.org/ |
| 90 | ------------ |
| 91 | |
| 92 | a URL like "git://example.org/path/to/repo.git" will be rewritten to |
| 93 | "ssh://example.org/path/to/repo.git" for pushes, but pulls will still |
| 94 | use the original URL. |