Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 1 | git-remote(1) |
| 2 | ============ |
| 3 | |
| 4 | NAME |
| 5 | ---- |
| 6 | git-remote - manage set of tracked repositories |
| 7 | |
| 8 | |
| 9 | SYNOPSIS |
| 10 | -------- |
| 11 | [verse] |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 12 | 'git remote' [-v | --verbose] |
Junio C Hamano | ee3adc3 | 2011-04-06 19:53:38 | [diff] [blame] | 13 | 'git remote add' [-t <branch>] [-m <master>] [-f] [--tags|--no-tags] [--mirror=<fetch|push>] <name> <url> |
Junio C Hamano | 2836349 | 2008-11-14 08:26:31 | [diff] [blame] | 14 | 'git remote rename' <old> <new> |
Junio C Hamano | 693e709 | 2012-09-12 22:56:53 | [diff] [blame] | 15 | 'git remote remove' <name> |
Junio C Hamano | bf984de | 2009-11-23 06:11:19 | [diff] [blame] | 16 | 'git remote set-head' <name> (-a | -d | <branch>) |
Junio C Hamano | e0238c2 | 2012-02-23 22:45:50 | [diff] [blame] | 17 | 'git remote set-branches' [--add] <name> <branch>... |
Junio C Hamano | 57827fb | 2010-01-23 03:02:50 | [diff] [blame] | 18 | 'git remote set-url' [--push] <name> <newurl> [<oldurl>] |
| 19 | 'git remote set-url --add' [--push] <name> <newurl> |
| 20 | 'git remote set-url --delete' [--push] <name> <url> |
Junio C Hamano | bf984de | 2009-11-23 06:11:19 | [diff] [blame] | 21 | 'git remote' [-v | --verbose] 'show' [-n] <name> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 22 | 'git remote prune' [-n | --dry-run] <name> |
Junio C Hamano | d2179ef | 2010-10-22 04:12:17 | [diff] [blame] | 23 | 'git remote' [-v | --verbose] 'update' [-p | --prune] [(<group> | <remote>)...] |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 24 | |
| 25 | DESCRIPTION |
| 26 | ----------- |
| 27 | |
| 28 | Manage the set of repositories ("remotes") whose branches you track. |
| 29 | |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 30 | |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 31 | OPTIONS |
| 32 | ------- |
| 33 | |
| 34 | -v:: |
| 35 | --verbose:: |
| 36 | Be a little more verbose and show remote url after name. |
Junio C Hamano | bf984de | 2009-11-23 06:11:19 | [diff] [blame] | 37 | NOTE: This must be placed between `remote` and `subcommand`. |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 38 | |
| 39 | |
Junio C Hamano | ee1e428 | 2007-02-04 08:32:04 | [diff] [blame] | 40 | COMMANDS |
| 41 | -------- |
| 42 | |
| 43 | With no arguments, shows a list of existing remotes. Several |
| 44 | subcommands are available to perform operations on the remotes. |
| 45 | |
| 46 | 'add':: |
| 47 | |
| 48 | Adds a remote named <name> for the repository at |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 49 | <url>. The command `git fetch <name>` can then be used to create and |
| 50 | update remote-tracking branches <name>/<branch>. |
Junio C Hamano | 17dde0e | 2007-02-26 09:50:21 | [diff] [blame] | 51 | + |
| 52 | With `-f` option, `git fetch <name>` is run immediately after |
| 53 | the remote information is set up. |
| 54 | + |
Junio C Hamano | cc7636a | 2010-05-21 14:57:53 | [diff] [blame] | 55 | With `--tags` option, `git fetch <name>` imports every tag from the |
| 56 | remote repository. |
| 57 | + |
| 58 | With `--no-tags` option, `git fetch <name>` does not import tags from |
| 59 | the remote repository. |
| 60 | + |
Junio C Hamano | 17dde0e | 2007-02-26 09:50:21 | [diff] [blame] | 61 | With `-t <branch>` option, instead of the default glob |
| 62 | refspec for the remote to track all branches under |
Junio C Hamano | 360e3a1 | 2011-07-13 23:51:56 | [diff] [blame] | 63 | the `refs/remotes/<name>/` namespace, a refspec to track only `<branch>` |
Junio C Hamano | 17dde0e | 2007-02-26 09:50:21 | [diff] [blame] | 64 | is created. You can give more than one `-t <branch>` to track |
Junio C Hamano | 67fad6d | 2007-05-06 08:53:12 | [diff] [blame] | 65 | multiple branches without grabbing all branches. |
Junio C Hamano | 17dde0e | 2007-02-26 09:50:21 | [diff] [blame] | 66 | + |
Junio C Hamano | 360e3a1 | 2011-07-13 23:51:56 | [diff] [blame] | 67 | With `-m <master>` option, a symbolic-ref `refs/remotes/<name>/HEAD` is set |
Junio C Hamano | d257cff | 2009-03-18 05:27:16 | [diff] [blame] | 68 | up to point at remote's `<master>` branch. See also the set-head command. |
Junio C Hamano | 58155b4 | 2007-09-15 07:46:14 | [diff] [blame] | 69 | + |
Junio C Hamano | b76a686 | 2012-05-02 22:02:46 | [diff] [blame] | 70 | When a fetch mirror is created with `--mirror=fetch`, the refs will not |
Junio C Hamano | ee3adc3 | 2011-04-06 19:53:38 | [diff] [blame] | 71 | be stored in the 'refs/remotes/' namespace, but rather everything in |
| 72 | 'refs/' on the remote will be directly mirrored into 'refs/' in the |
| 73 | local repository. This option only makes sense in bare repositories, |
| 74 | because a fetch would overwrite any local commits. |
| 75 | + |
Junio C Hamano | b76a686 | 2012-05-02 22:02:46 | [diff] [blame] | 76 | When a push mirror is created with `--mirror=push`, then `git push` |
| 77 | will always behave as if `--mirror` was passed. |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 78 | |
Junio C Hamano | 2836349 | 2008-11-14 08:26:31 | [diff] [blame] | 79 | 'rename':: |
| 80 | |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 81 | Rename the remote named <old> to <new>. All remote-tracking branches and |
Junio C Hamano | 2836349 | 2008-11-14 08:26:31 | [diff] [blame] | 82 | configuration settings for the remote are updated. |
| 83 | + |
| 84 | In case <old> and <new> are the same, and <old> is a file under |
| 85 | `$GIT_DIR/remotes` or `$GIT_DIR/branches`, the remote is converted to |
| 86 | the configuration file format. |
| 87 | |
Junio C Hamano | 693e709 | 2012-09-12 22:56:53 | [diff] [blame] | 88 | 'remove':: |
Junio C Hamano | 4fd58d4 | 2007-09-30 00:51:14 | [diff] [blame] | 89 | 'rm':: |
| 90 | |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 91 | Remove the remote named <name>. All remote-tracking branches and |
Junio C Hamano | 4fd58d4 | 2007-09-30 00:51:14 | [diff] [blame] | 92 | configuration settings for the remote are removed. |
| 93 | |
Junio C Hamano | d257cff | 2009-03-18 05:27:16 | [diff] [blame] | 94 | 'set-head':: |
| 95 | |
Junio C Hamano | 360e3a1 | 2011-07-13 23:51:56 | [diff] [blame] | 96 | Sets or deletes the default branch (i.e. the target of the |
| 97 | symbolic-ref `refs/remotes/<name>/HEAD`) for |
Junio C Hamano | d257cff | 2009-03-18 05:27:16 | [diff] [blame] | 98 | the named remote. Having a default branch for a remote is not required, |
| 99 | but allows the name of the remote to be specified in lieu of a specific |
| 100 | branch. For example, if the default branch for `origin` is set to |
| 101 | `master`, then `origin` may be specified wherever you would normally |
| 102 | specify `origin/master`. |
| 103 | + |
Junio C Hamano | 360e3a1 | 2011-07-13 23:51:56 | [diff] [blame] | 104 | With `-d`, the symbolic ref `refs/remotes/<name>/HEAD` is deleted. |
Junio C Hamano | d257cff | 2009-03-18 05:27:16 | [diff] [blame] | 105 | + |
Junio C Hamano | 360e3a1 | 2011-07-13 23:51:56 | [diff] [blame] | 106 | With `-a`, the remote is queried to determine its `HEAD`, then the |
| 107 | symbolic-ref `refs/remotes/<name>/HEAD` is set to the same branch. e.g., if the remote |
Junio C Hamano | d257cff | 2009-03-18 05:27:16 | [diff] [blame] | 108 | `HEAD` is pointed at `next`, "`git remote set-head origin -a`" will set |
Junio C Hamano | 360e3a1 | 2011-07-13 23:51:56 | [diff] [blame] | 109 | the symbolic-ref `refs/remotes/origin/HEAD` to `refs/remotes/origin/next`. This will |
Junio C Hamano | d257cff | 2009-03-18 05:27:16 | [diff] [blame] | 110 | only work if `refs/remotes/origin/next` already exists; if not it must be |
| 111 | fetched first. |
| 112 | + |
Junio C Hamano | 360e3a1 | 2011-07-13 23:51:56 | [diff] [blame] | 113 | Use `<branch>` to set the symbolic-ref `refs/remotes/<name>/HEAD` explicitly. e.g., "git |
| 114 | remote set-head origin master" will set the symbolic-ref `refs/remotes/origin/HEAD` to |
Junio C Hamano | d257cff | 2009-03-18 05:27:16 | [diff] [blame] | 115 | `refs/remotes/origin/master`. This will only work if |
| 116 | `refs/remotes/origin/master` already exists; if not it must be fetched first. |
| 117 | + |
| 118 | |
Junio C Hamano | f5de4cf | 2010-06-19 00:33:17 | [diff] [blame] | 119 | 'set-branches':: |
| 120 | |
| 121 | Changes the list of branches tracked by the named remote. |
| 122 | This can be used to track a subset of the available remote branches |
| 123 | after the initial setup for a remote. |
| 124 | + |
| 125 | The named branches will be interpreted as if specified with the |
| 126 | `-t` option on the 'git remote add' command line. |
| 127 | + |
| 128 | With `--add`, instead of replacing the list of currently tracked |
| 129 | branches, adds to that list. |
| 130 | |
Junio C Hamano | 57827fb | 2010-01-23 03:02:50 | [diff] [blame] | 131 | 'set-url':: |
| 132 | |
| 133 | Changes URL remote points to. Sets first URL remote points to matching |
| 134 | regex <oldurl> (first URL if no <oldurl> is given) to <newurl>. If |
| 135 | <oldurl> doesn't match any URL, error occurs and nothing is changed. |
| 136 | + |
| 137 | With '--push', push URLs are manipulated instead of fetch URLs. |
| 138 | + |
| 139 | With '--add', instead of changing some URL, new URL is added. |
| 140 | + |
| 141 | With '--delete', instead of changing some URL, all URLs matching |
| 142 | regex <url> are deleted. Trying to delete all non-push URLs is an |
| 143 | error. |
| 144 | |
Junio C Hamano | ee1e428 | 2007-02-04 08:32:04 | [diff] [blame] | 145 | 'show':: |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 146 | |
Junio C Hamano | ee1e428 | 2007-02-04 08:32:04 | [diff] [blame] | 147 | Gives some information about the remote <name>. |
Junio C Hamano | 401939f | 2007-07-01 06:34:30 | [diff] [blame] | 148 | + |
| 149 | With `-n` option, the remote heads are not queried first with |
| 150 | `git ls-remote <name>`; cached information is used instead. |
Junio C Hamano | ee1e428 | 2007-02-04 08:32:04 | [diff] [blame] | 151 | |
| 152 | 'prune':: |
| 153 | |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 154 | Deletes all stale remote-tracking branches under <name>. |
Junio C Hamano | 39381a7 | 2007-02-02 07:35:15 | [diff] [blame] | 155 | These stale branches have already been removed from the remote repository |
Junio C Hamano | 0bbd467 | 2007-02-20 04:52:14 | [diff] [blame] | 156 | referenced by <name>, but are still locally available in |
| 157 | "remotes/<name>". |
Junio C Hamano | 401939f | 2007-07-01 06:34:30 | [diff] [blame] | 158 | + |
Junio C Hamano | 9f88386 | 2009-08-11 06:23:52 | [diff] [blame] | 159 | With `--dry-run` option, report what branches will be pruned, but do not |
Junio C Hamano | 6fb124c | 2008-06-13 10:04:01 | [diff] [blame] | 160 | actually prune them. |
Junio C Hamano | 0bbd467 | 2007-02-20 04:52:14 | [diff] [blame] | 161 | |
| 162 | 'update':: |
| 163 | |
Junio C Hamano | 118d277 | 2007-02-21 20:24:10 | [diff] [blame] | 164 | Fetch updates for a named set of remotes in the repository as defined by |
| 165 | remotes.<group>. If a named group is not specified on the command line, |
Junio C Hamano | 9f88386 | 2009-08-11 06:23:52 | [diff] [blame] | 166 | the configuration parameter remotes.default will be used; if |
Junio C Hamano | 361c133 | 2007-11-14 12:17:22 | [diff] [blame] | 167 | remotes.default is not defined, all remotes which do not have the |
Junio C Hamano | 118d277 | 2007-02-21 20:24:10 | [diff] [blame] | 168 | configuration parameter remote.<name>.skipDefaultUpdate set to true will |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 169 | be updated. (See linkgit:git-config[1]). |
Junio C Hamano | 98e32c3 | 2009-04-13 02:39:53 | [diff] [blame] | 170 | + |
| 171 | With `--prune` option, prune all the remotes that are updated. |
Junio C Hamano | 39381a7 | 2007-02-02 07:35:15 | [diff] [blame] | 172 | |
Junio C Hamano | ee1e428 | 2007-02-04 08:32:04 | [diff] [blame] | 173 | |
| 174 | DISCUSSION |
| 175 | ---------- |
| 176 | |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 177 | The remote configuration is achieved using the `remote.origin.url` and |
| 178 | `remote.origin.fetch` configuration variables. (See |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 179 | linkgit:git-config[1]). |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 180 | |
| 181 | Examples |
| 182 | -------- |
| 183 | |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 184 | * Add a new remote, fetch, and check out a branch from it |
| 185 | + |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 186 | ------------ |
| 187 | $ git remote |
| 188 | origin |
| 189 | $ git branch -r |
| 190 | origin/master |
Junio C Hamano | 393e57f | 2007-11-20 04:53:25 | [diff] [blame] | 191 | $ git remote add linux-nfs git://linux-nfs.org/pub/linux/nfs-2.6.git |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 192 | $ git remote |
| 193 | linux-nfs |
| 194 | origin |
| 195 | $ git fetch |
| 196 | * refs/remotes/linux-nfs/master: storing branch 'master' ... |
| 197 | commit: bf81b46 |
| 198 | $ git branch -r |
| 199 | origin/master |
| 200 | linux-nfs/master |
| 201 | $ git checkout -b nfs linux-nfs/master |
| 202 | ... |
| 203 | ------------ |
| 204 | |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 205 | * Imitate 'git clone' but track only selected branches |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 206 | + |
| 207 | ------------ |
| 208 | $ mkdir project.git |
| 209 | $ cd project.git |
| 210 | $ git init |
| 211 | $ git remote add -f -t master -m master origin git://example.com/git.git/ |
| 212 | $ git merge origin |
| 213 | ------------ |
| 214 | |
| 215 | |
Junio C Hamano | 9049d91 | 2008-05-29 02:09:50 | [diff] [blame] | 216 | SEE ALSO |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 217 | -------- |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 218 | linkgit:git-fetch[1] |
| 219 | linkgit:git-branch[1] |
| 220 | linkgit:git-config[1] |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 221 | |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 222 | GIT |
| 223 | --- |
Junio C Hamano | f7c042d | 2008-06-06 22:50:53 | [diff] [blame] | 224 | Part of the linkgit:git[1] suite |