Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 1 | git-remote(1) |
Junio C Hamano | ee61580 | 2015-10-29 21:45:26 | [diff] [blame] | 2 | ============= |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 3 | |
| 4 | NAME |
| 5 | ---- |
Junio C Hamano | 5b3533d | 2014-02-27 23:07:15 | [diff] [blame] | 6 | git-remote - Manage set of tracked repositories |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 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 | 59a32b0 | 2021-12-10 22:53:38 | [diff] [blame] | 13 | 'git remote add' [-t <branch>] [-m <master>] [-f] [--[no-]tags] [--mirror=(fetch|push)] <name> <URL> |
Junio C Hamano | 14390e2 | 2022-03-17 01:11:12 | [diff] [blame] | 14 | 'git remote rename' [--[no-]progress] <old> <new> |
Junio C Hamano | 693e709 | 2012-09-12 22:56:53 | [diff] [blame] | 15 | 'git remote remove' <name> |
Junio C Hamano | 369e340 | 2013-10-15 18:40:25 | [diff] [blame] | 16 | 'git remote set-head' <name> (-a | --auto | -d | --delete | <branch>) |
Junio C Hamano | e0238c2 | 2012-02-23 22:45:50 | [diff] [blame] | 17 | 'git remote set-branches' [--add] <name> <branch>... |
Junio C Hamano | 1eb5609 | 2015-10-05 20:39:53 | [diff] [blame] | 18 | 'git remote get-url' [--push] [--all] <name> |
Junio C Hamano | 57827fb | 2010-01-23 03:02:50 | [diff] [blame] | 19 | 'git remote set-url' [--push] <name> <newurl> [<oldurl>] |
| 20 | 'git remote set-url --add' [--push] <name> <newurl> |
Junio C Hamano | 59a32b0 | 2021-12-10 22:53:38 | [diff] [blame] | 21 | 'git remote set-url --delete' [--push] <name> <URL> |
Junio C Hamano | 5a6d5f7 | 2013-05-01 23:37:03 | [diff] [blame] | 22 | 'git remote' [-v | --verbose] 'show' [-n] <name>... |
| 23 | 'git remote prune' [-n | --dry-run] <name>... |
Junio C Hamano | d2179ef | 2010-10-22 04:12:17 | [diff] [blame] | 24 | 'git remote' [-v | --verbose] 'update' [-p | --prune] [(<group> | <remote>)...] |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 25 | |
| 26 | DESCRIPTION |
| 27 | ----------- |
| 28 | |
| 29 | Manage the set of repositories ("remotes") whose branches you track. |
| 30 | |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 31 | |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 32 | OPTIONS |
| 33 | ------- |
| 34 | |
| 35 | -v:: |
| 36 | --verbose:: |
| 37 | Be a little more verbose and show remote url after name. |
Junio C Hamano | 37db4ad | 2022-05-26 23:14:04 | [diff] [blame] | 38 | For promisor remotes, also show which filter (`blob:none` etc.) |
| 39 | are configured. |
Junio C Hamano | cba446b | 2020-10-09 15:51:15 | [diff] [blame] | 40 | NOTE: This must be placed between `remote` and subcommand. |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 41 | |
| 42 | |
Junio C Hamano | ee1e428 | 2007-02-04 08:32:04 | [diff] [blame] | 43 | COMMANDS |
| 44 | -------- |
| 45 | |
| 46 | With no arguments, shows a list of existing remotes. Several |
| 47 | subcommands are available to perform operations on the remotes. |
| 48 | |
| 49 | 'add':: |
| 50 | |
Junio C Hamano | cba446b | 2020-10-09 15:51:15 | [diff] [blame] | 51 | Add a remote named <name> for the repository at |
Junio C Hamano | 59a32b0 | 2021-12-10 22:53:38 | [diff] [blame] | 52 | <URL>. The command `git fetch <name>` can then be used to create and |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 53 | update remote-tracking branches <name>/<branch>. |
Junio C Hamano | 17dde0e | 2007-02-26 09:50:21 | [diff] [blame] | 54 | + |
| 55 | With `-f` option, `git fetch <name>` is run immediately after |
| 56 | the remote information is set up. |
| 57 | + |
Junio C Hamano | cc7636a | 2010-05-21 14:57:53 | [diff] [blame] | 58 | With `--tags` option, `git fetch <name>` imports every tag from the |
| 59 | remote repository. |
| 60 | + |
| 61 | With `--no-tags` option, `git fetch <name>` does not import tags from |
| 62 | the remote repository. |
| 63 | + |
Junio C Hamano | 6bf68cf | 2015-03-06 23:46:29 | [diff] [blame] | 64 | By default, only tags on fetched branches are imported |
| 65 | (see linkgit:git-fetch[1]). |
| 66 | + |
Junio C Hamano | 17dde0e | 2007-02-26 09:50:21 | [diff] [blame] | 67 | With `-t <branch>` option, instead of the default glob |
| 68 | refspec for the remote to track all branches under |
Junio C Hamano | 360e3a1 | 2011-07-13 23:51:56 | [diff] [blame] | 69 | the `refs/remotes/<name>/` namespace, a refspec to track only `<branch>` |
Junio C Hamano | 17dde0e | 2007-02-26 09:50:21 | [diff] [blame] | 70 | is created. You can give more than one `-t <branch>` to track |
Junio C Hamano | 67fad6d | 2007-05-06 08:53:12 | [diff] [blame] | 71 | multiple branches without grabbing all branches. |
Junio C Hamano | 17dde0e | 2007-02-26 09:50:21 | [diff] [blame] | 72 | + |
Junio C Hamano | 360e3a1 | 2011-07-13 23:51:56 | [diff] [blame] | 73 | 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] | 74 | 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] | 75 | + |
Junio C Hamano | b76a686 | 2012-05-02 22:02:46 | [diff] [blame] | 76 | 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] | 77 | be stored in the 'refs/remotes/' namespace, but rather everything in |
| 78 | 'refs/' on the remote will be directly mirrored into 'refs/' in the |
| 79 | local repository. This option only makes sense in bare repositories, |
| 80 | because a fetch would overwrite any local commits. |
| 81 | + |
Junio C Hamano | b76a686 | 2012-05-02 22:02:46 | [diff] [blame] | 82 | When a push mirror is created with `--mirror=push`, then `git push` |
| 83 | will always behave as if `--mirror` was passed. |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 84 | |
Junio C Hamano | 2836349 | 2008-11-14 08:26:31 | [diff] [blame] | 85 | 'rename':: |
| 86 | |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 87 | Rename the remote named <old> to <new>. All remote-tracking branches and |
Junio C Hamano | 2836349 | 2008-11-14 08:26:31 | [diff] [blame] | 88 | configuration settings for the remote are updated. |
| 89 | + |
| 90 | In case <old> and <new> are the same, and <old> is a file under |
| 91 | `$GIT_DIR/remotes` or `$GIT_DIR/branches`, the remote is converted to |
| 92 | the configuration file format. |
| 93 | |
Junio C Hamano | 693e709 | 2012-09-12 22:56:53 | [diff] [blame] | 94 | 'remove':: |
Junio C Hamano | 4fd58d4 | 2007-09-30 00:51:14 | [diff] [blame] | 95 | 'rm':: |
| 96 | |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 97 | Remove the remote named <name>. All remote-tracking branches and |
Junio C Hamano | 4fd58d4 | 2007-09-30 00:51:14 | [diff] [blame] | 98 | configuration settings for the remote are removed. |
| 99 | |
Junio C Hamano | d257cff | 2009-03-18 05:27:16 | [diff] [blame] | 100 | 'set-head':: |
| 101 | |
Junio C Hamano | 360e3a1 | 2011-07-13 23:51:56 | [diff] [blame] | 102 | Sets or deletes the default branch (i.e. the target of the |
| 103 | symbolic-ref `refs/remotes/<name>/HEAD`) for |
Junio C Hamano | d257cff | 2009-03-18 05:27:16 | [diff] [blame] | 104 | the named remote. Having a default branch for a remote is not required, |
| 105 | but allows the name of the remote to be specified in lieu of a specific |
| 106 | branch. For example, if the default branch for `origin` is set to |
| 107 | `master`, then `origin` may be specified wherever you would normally |
| 108 | specify `origin/master`. |
| 109 | + |
Junio C Hamano | 369e340 | 2013-10-15 18:40:25 | [diff] [blame] | 110 | With `-d` or `--delete`, the symbolic ref `refs/remotes/<name>/HEAD` is deleted. |
Junio C Hamano | d257cff | 2009-03-18 05:27:16 | [diff] [blame] | 111 | + |
Junio C Hamano | 369e340 | 2013-10-15 18:40:25 | [diff] [blame] | 112 | With `-a` or `--auto`, the remote is queried to determine its `HEAD`, then the |
Junio C Hamano | 360e3a1 | 2011-07-13 23:51:56 | [diff] [blame] | 113 | symbolic-ref `refs/remotes/<name>/HEAD` is set to the same branch. e.g., if the remote |
Junio C Hamano | cba446b | 2020-10-09 15:51:15 | [diff] [blame] | 114 | `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] | 115 | 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] | 116 | only work if `refs/remotes/origin/next` already exists; if not it must be |
| 117 | fetched first. |
| 118 | + |
Junio C Hamano | cba446b | 2020-10-09 15:51:15 | [diff] [blame] | 119 | Use `<branch>` to set the symbolic-ref `refs/remotes/<name>/HEAD` explicitly. e.g., `git |
| 120 | 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] | 121 | `refs/remotes/origin/master`. This will only work if |
| 122 | `refs/remotes/origin/master` already exists; if not it must be fetched first. |
| 123 | + |
| 124 | |
Junio C Hamano | f5de4cf | 2010-06-19 00:33:17 | [diff] [blame] | 125 | 'set-branches':: |
| 126 | |
| 127 | Changes the list of branches tracked by the named remote. |
| 128 | This can be used to track a subset of the available remote branches |
| 129 | after the initial setup for a remote. |
| 130 | + |
| 131 | The named branches will be interpreted as if specified with the |
Junio C Hamano | cba446b | 2020-10-09 15:51:15 | [diff] [blame] | 132 | `-t` option on the `git remote add` command line. |
Junio C Hamano | f5de4cf | 2010-06-19 00:33:17 | [diff] [blame] | 133 | + |
| 134 | With `--add`, instead of replacing the list of currently tracked |
| 135 | branches, adds to that list. |
| 136 | |
Junio C Hamano | 1eb5609 | 2015-10-05 20:39:53 | [diff] [blame] | 137 | 'get-url':: |
| 138 | |
| 139 | Retrieves the URLs for a remote. Configurations for `insteadOf` and |
| 140 | `pushInsteadOf` are expanded here. By default, only the first URL is listed. |
| 141 | + |
Junio C Hamano | 92d8037 | 2016-07-13 22:00:05 | [diff] [blame] | 142 | With `--push`, push URLs are queried rather than fetch URLs. |
Junio C Hamano | 1eb5609 | 2015-10-05 20:39:53 | [diff] [blame] | 143 | + |
Junio C Hamano | 92d8037 | 2016-07-13 22:00:05 | [diff] [blame] | 144 | With `--all`, all URLs for the remote will be listed. |
Junio C Hamano | 1eb5609 | 2015-10-05 20:39:53 | [diff] [blame] | 145 | |
Junio C Hamano | 57827fb | 2010-01-23 03:02:50 | [diff] [blame] | 146 | 'set-url':: |
| 147 | |
Junio C Hamano | c355030 | 2015-02-18 22:34:11 | [diff] [blame] | 148 | Changes URLs for the remote. Sets first URL for remote <name> that matches |
Junio C Hamano | 57827fb | 2010-01-23 03:02:50 | [diff] [blame] | 149 | regex <oldurl> (first URL if no <oldurl> is given) to <newurl>. If |
Junio C Hamano | c355030 | 2015-02-18 22:34:11 | [diff] [blame] | 150 | <oldurl> doesn't match any URL, an error occurs and nothing is changed. |
Junio C Hamano | 57827fb | 2010-01-23 03:02:50 | [diff] [blame] | 151 | + |
Junio C Hamano | 92d8037 | 2016-07-13 22:00:05 | [diff] [blame] | 152 | With `--push`, push URLs are manipulated instead of fetch URLs. |
Junio C Hamano | 57827fb | 2010-01-23 03:02:50 | [diff] [blame] | 153 | + |
Junio C Hamano | 92d8037 | 2016-07-13 22:00:05 | [diff] [blame] | 154 | With `--add`, instead of changing existing URLs, new URL is added. |
Junio C Hamano | 57827fb | 2010-01-23 03:02:50 | [diff] [blame] | 155 | + |
Junio C Hamano | 92d8037 | 2016-07-13 22:00:05 | [diff] [blame] | 156 | With `--delete`, instead of changing existing URLs, all URLs matching |
Junio C Hamano | 59a32b0 | 2021-12-10 22:53:38 | [diff] [blame] | 157 | regex <URL> are deleted for remote <name>. Trying to delete all |
Junio C Hamano | c355030 | 2015-02-18 22:34:11 | [diff] [blame] | 158 | non-push URLs is an error. |
| 159 | + |
| 160 | Note that the push URL and the fetch URL, even though they can |
| 161 | be set differently, must still refer to the same place. What you |
| 162 | pushed to the push URL should be what you would see if you |
| 163 | immediately fetched from the fetch URL. If you are trying to |
| 164 | fetch from one place (e.g. your upstream) and push to another (e.g. |
| 165 | your publishing repository), use two separate remotes. |
| 166 | |
Junio C Hamano | 57827fb | 2010-01-23 03:02:50 | [diff] [blame] | 167 | |
Junio C Hamano | ee1e428 | 2007-02-04 08:32:04 | [diff] [blame] | 168 | 'show':: |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 169 | |
Junio C Hamano | ee1e428 | 2007-02-04 08:32:04 | [diff] [blame] | 170 | Gives some information about the remote <name>. |
Junio C Hamano | 401939f | 2007-07-01 06:34:30 | [diff] [blame] | 171 | + |
| 172 | With `-n` option, the remote heads are not queried first with |
| 173 | `git ls-remote <name>`; cached information is used instead. |
Junio C Hamano | ee1e428 | 2007-02-04 08:32:04 | [diff] [blame] | 174 | |
| 175 | 'prune':: |
| 176 | |
Junio C Hamano | 664750f | 2018-03-06 23:25:44 | [diff] [blame] | 177 | Deletes stale references associated with <name>. By default, stale |
| 178 | remote-tracking branches under <name> are deleted, but depending on |
| 179 | global configuration and the configuration of the remote we might even |
| 180 | prune local tags that haven't been pushed there. Equivalent to `git |
| 181 | fetch --prune <name>`, except that no new references will be fetched. |
| 182 | + |
| 183 | See the PRUNING section of linkgit:git-fetch[1] for what it'll prune |
| 184 | depending on various configuration. |
Junio C Hamano | 401939f | 2007-07-01 06:34:30 | [diff] [blame] | 185 | + |
Junio C Hamano | cba446b | 2020-10-09 15:51:15 | [diff] [blame] | 186 | With `--dry-run` option, report what branches would be pruned, but do not |
Junio C Hamano | 6fb124c | 2008-06-13 10:04:01 | [diff] [blame] | 187 | actually prune them. |
Junio C Hamano | 0bbd467 | 2007-02-20 04:52:14 | [diff] [blame] | 188 | |
| 189 | 'update':: |
| 190 | |
Junio C Hamano | 4dca903 | 2018-06-04 13:49:31 | [diff] [blame] | 191 | Fetch updates for remotes or remote groups in the repository as defined by |
Junio C Hamano | cba446b | 2020-10-09 15:51:15 | [diff] [blame] | 192 | `remotes.<group>`. If neither group nor remote is specified on the command line, |
Junio C Hamano | 9f88386 | 2009-08-11 06:23:52 | [diff] [blame] | 193 | the configuration parameter remotes.default will be used; if |
Junio C Hamano | 361c133 | 2007-11-14 12:17:22 | [diff] [blame] | 194 | remotes.default is not defined, all remotes which do not have the |
Junio C Hamano | cba446b | 2020-10-09 15:51:15 | [diff] [blame] | 195 | configuration parameter `remote.<name>.skipDefaultUpdate` set to true will |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 196 | be updated. (See linkgit:git-config[1]). |
Junio C Hamano | 98e32c3 | 2009-04-13 02:39:53 | [diff] [blame] | 197 | + |
Junio C Hamano | 664750f | 2018-03-06 23:25:44 | [diff] [blame] | 198 | With `--prune` option, run pruning against all the remotes that are updated. |
Junio C Hamano | 39381a7 | 2007-02-02 07:35:15 | [diff] [blame] | 199 | |
Junio C Hamano | ee1e428 | 2007-02-04 08:32:04 | [diff] [blame] | 200 | |
| 201 | DISCUSSION |
| 202 | ---------- |
| 203 | |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 204 | The remote configuration is achieved using the `remote.origin.url` and |
| 205 | `remote.origin.fetch` configuration variables. (See |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 206 | linkgit:git-config[1]). |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 207 | |
Junio C Hamano | a65c1f4 | 2020-11-09 22:50:11 | [diff] [blame] | 208 | EXIT STATUS |
| 209 | ----------- |
| 210 | |
| 211 | On success, the exit status is `0`. |
| 212 | |
| 213 | When subcommands such as 'add', 'rename', and 'remove' can't find the |
| 214 | remote in question, the exit status is `2`. When the remote already |
| 215 | exists, the exit status is `3`. |
| 216 | |
| 217 | On any other error, the exit status may be any other non-zero value. |
| 218 | |
Junio C Hamano | b9d9d90 | 2018-05-23 07:07:42 | [diff] [blame] | 219 | EXAMPLES |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 220 | -------- |
| 221 | |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 222 | * Add a new remote, fetch, and check out a branch from it |
| 223 | + |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 224 | ------------ |
| 225 | $ git remote |
| 226 | origin |
| 227 | $ git branch -r |
Junio C Hamano | a195230 | 2013-07-01 21:31:18 | [diff] [blame] | 228 | origin/HEAD -> origin/master |
| 229 | origin/master |
| 230 | $ git remote add staging git://git.kernel.org/.../gregkh/staging.git |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 231 | $ git remote |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 232 | origin |
Junio C Hamano | a195230 | 2013-07-01 21:31:18 | [diff] [blame] | 233 | staging |
| 234 | $ git fetch staging |
| 235 | ... |
| 236 | From git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging |
| 237 | * [new branch] master -> staging/master |
| 238 | * [new branch] staging-linus -> staging/staging-linus |
| 239 | * [new branch] staging-next -> staging/staging-next |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 240 | $ git branch -r |
Junio C Hamano | a195230 | 2013-07-01 21:31:18 | [diff] [blame] | 241 | origin/HEAD -> origin/master |
| 242 | origin/master |
| 243 | staging/master |
| 244 | staging/staging-linus |
| 245 | staging/staging-next |
Junio C Hamano | c9f11c2 | 2019-07-10 02:54:04 | [diff] [blame] | 246 | $ git switch -c staging staging/master |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 247 | ... |
| 248 | ------------ |
| 249 | |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 250 | * Imitate 'git clone' but track only selected branches |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 251 | + |
| 252 | ------------ |
| 253 | $ mkdir project.git |
| 254 | $ cd project.git |
| 255 | $ git init |
| 256 | $ git remote add -f -t master -m master origin git://example.com/git.git/ |
| 257 | $ git merge origin |
| 258 | ------------ |
| 259 | |
| 260 | |
Junio C Hamano | 9049d91 | 2008-05-29 02:09:50 | [diff] [blame] | 261 | SEE ALSO |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 262 | -------- |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 263 | linkgit:git-fetch[1] |
| 264 | linkgit:git-branch[1] |
| 265 | linkgit:git-config[1] |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 266 | |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 267 | GIT |
| 268 | --- |
Junio C Hamano | f7c042d | 2008-06-06 22:50:53 | [diff] [blame] | 269 | Part of the linkgit:git[1] suite |