blob: 1dec3148348350bc6f26a53ca2add524d3f8b9bf [file] [log] [blame]
Junio C Hamano1d3a6c72007-01-09 11:13:471git-remote(1)
Junio C Hamanoee615802015-10-29 21:45:262=============
Junio C Hamano1d3a6c72007-01-09 11:13:473
4NAME
5----
Junio C Hamano5b3533d2014-02-27 23:07:156git-remote - Manage set of tracked repositories
Junio C Hamano1d3a6c72007-01-09 11:13:477
8
9SYNOPSIS
10--------
11[verse]
Junio C Hamanofce7c7e2008-07-02 03:06:3812'git remote' [-v | --verbose]
Junio C Hamano59a32b02021-12-10 22:53:3813'git remote add' [-t <branch>] [-m <master>] [-f] [--[no-]tags] [--mirror=(fetch|push)] <name> <URL>
Junio C Hamano14390e22022-03-17 01:11:1214'git remote rename' [--[no-]progress] <old> <new>
Junio C Hamano693e7092012-09-12 22:56:5315'git remote remove' <name>
Junio C Hamano369e3402013-10-15 18:40:2516'git remote set-head' <name> (-a | --auto | -d | --delete | <branch>)
Junio C Hamanoe0238c22012-02-23 22:45:5017'git remote set-branches' [--add] <name> <branch>...
Junio C Hamano1eb56092015-10-05 20:39:5318'git remote get-url' [--push] [--all] <name>
Junio C Hamano57827fb2010-01-23 03:02:5019'git remote set-url' [--push] <name> <newurl> [<oldurl>]
20'git remote set-url --add' [--push] <name> <newurl>
Junio C Hamano59a32b02021-12-10 22:53:3821'git remote set-url --delete' [--push] <name> <URL>
Junio C Hamano5a6d5f72013-05-01 23:37:0322'git remote' [-v | --verbose] 'show' [-n] <name>...
23'git remote prune' [-n | --dry-run] <name>...
Junio C Hamanod2179ef2010-10-22 04:12:1724'git remote' [-v | --verbose] 'update' [-p | --prune] [(<group> | <remote>)...]
Junio C Hamano1d3a6c72007-01-09 11:13:4725
26DESCRIPTION
27-----------
28
29Manage the set of repositories ("remotes") whose branches you track.
30
Junio C Hamano1d3a6c72007-01-09 11:13:4731
Junio C Hamanoeb415992008-06-08 22:49:4732OPTIONS
33-------
34
35-v::
36--verbose::
37Be a little more verbose and show remote url after name.
Junio C Hamano37db4ad2022-05-26 23:14:0438For promisor remotes, also show which filter (`blob:none` etc.)
39are configured.
Junio C Hamanocba446b2020-10-09 15:51:1540NOTE: This must be placed between `remote` and subcommand.
Junio C Hamanoeb415992008-06-08 22:49:4741
42
Junio C Hamanoee1e4282007-02-04 08:32:0443COMMANDS
44--------
45
46With no arguments, shows a list of existing remotes. Several
47subcommands are available to perform operations on the remotes.
48
49'add'::
50
Junio C Hamanocba446b2020-10-09 15:51:1551Add a remote named <name> for the repository at
Junio C Hamano59a32b02021-12-10 22:53:3852<URL>. The command `git fetch <name>` can then be used to create and
Junio C Hamano1d3a6c72007-01-09 11:13:4753update remote-tracking branches <name>/<branch>.
Junio C Hamano17dde0e2007-02-26 09:50:2154+
55With `-f` option, `git fetch <name>` is run immediately after
56the remote information is set up.
57+
Junio C Hamanocc7636a2010-05-21 14:57:5358With `--tags` option, `git fetch <name>` imports every tag from the
59remote repository.
60+
61With `--no-tags` option, `git fetch <name>` does not import tags from
62the remote repository.
63+
Junio C Hamano6bf68cf2015-03-06 23:46:2964By default, only tags on fetched branches are imported
65(see linkgit:git-fetch[1]).
66+
Junio C Hamano17dde0e2007-02-26 09:50:2167With `-t <branch>` option, instead of the default glob
68refspec for the remote to track all branches under
Junio C Hamano360e3a12011-07-13 23:51:5669the `refs/remotes/<name>/` namespace, a refspec to track only `<branch>`
Junio C Hamano17dde0e2007-02-26 09:50:2170is created. You can give more than one `-t <branch>` to track
Junio C Hamano67fad6d2007-05-06 08:53:1271multiple branches without grabbing all branches.
Junio C Hamano17dde0e2007-02-26 09:50:2172+
Junio C Hamano360e3a12011-07-13 23:51:5673With `-m <master>` option, a symbolic-ref `refs/remotes/<name>/HEAD` is set
Junio C Hamanod257cff2009-03-18 05:27:1674up to point at remote's `<master>` branch. See also the set-head command.
Junio C Hamano58155b42007-09-15 07:46:1475+
Junio C Hamanob76a6862012-05-02 22:02:4676When a fetch mirror is created with `--mirror=fetch`, the refs will not
Junio C Hamanoee3adc32011-04-06 19:53:3877be stored in the 'refs/remotes/' namespace, but rather everything in
78'refs/' on the remote will be directly mirrored into 'refs/' in the
79local repository. This option only makes sense in bare repositories,
80because a fetch would overwrite any local commits.
81+
Junio C Hamanob76a6862012-05-02 22:02:4682When a push mirror is created with `--mirror=push`, then `git push`
83will always behave as if `--mirror` was passed.
Junio C Hamano1d3a6c72007-01-09 11:13:4784
Junio C Hamano28363492008-11-14 08:26:3185'rename'::
86
Junio C Hamano97bcb482010-11-25 03:16:0787Rename the remote named <old> to <new>. All remote-tracking branches and
Junio C Hamano28363492008-11-14 08:26:3188configuration settings for the remote are updated.
89+
90In 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
92the configuration file format.
93
Junio C Hamano693e7092012-09-12 22:56:5394'remove'::
Junio C Hamano4fd58d42007-09-30 00:51:1495'rm'::
96
Junio C Hamano97bcb482010-11-25 03:16:0797Remove the remote named <name>. All remote-tracking branches and
Junio C Hamano4fd58d42007-09-30 00:51:1498configuration settings for the remote are removed.
99
Junio C Hamanod257cff2009-03-18 05:27:16100'set-head'::
101
Junio C Hamano360e3a12011-07-13 23:51:56102Sets or deletes the default branch (i.e. the target of the
103symbolic-ref `refs/remotes/<name>/HEAD`) for
Junio C Hamanod257cff2009-03-18 05:27:16104the named remote. Having a default branch for a remote is not required,
105but allows the name of the remote to be specified in lieu of a specific
106branch. For example, if the default branch for `origin` is set to
107`master`, then `origin` may be specified wherever you would normally
108specify `origin/master`.
109+
Junio C Hamano369e3402013-10-15 18:40:25110With `-d` or `--delete`, the symbolic ref `refs/remotes/<name>/HEAD` is deleted.
Junio C Hamanod257cff2009-03-18 05:27:16111+
Junio C Hamano369e3402013-10-15 18:40:25112With `-a` or `--auto`, the remote is queried to determine its `HEAD`, then the
Junio C Hamano360e3a12011-07-13 23:51:56113symbolic-ref `refs/remotes/<name>/HEAD` is set to the same branch. e.g., if the remote
Junio C Hamanocba446b2020-10-09 15:51:15114`HEAD` is pointed at `next`, `git remote set-head origin -a` will set
Junio C Hamano360e3a12011-07-13 23:51:56115the symbolic-ref `refs/remotes/origin/HEAD` to `refs/remotes/origin/next`. This will
Junio C Hamanod257cff2009-03-18 05:27:16116only work if `refs/remotes/origin/next` already exists; if not it must be
117fetched first.
118+
Junio C Hamanocba446b2020-10-09 15:51:15119Use `<branch>` to set the symbolic-ref `refs/remotes/<name>/HEAD` explicitly. e.g., `git
120remote set-head origin master` will set the symbolic-ref `refs/remotes/origin/HEAD` to
Junio C Hamanod257cff2009-03-18 05:27:16121`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 Hamanof5de4cf2010-06-19 00:33:17125'set-branches'::
126
127Changes the list of branches tracked by the named remote.
128This can be used to track a subset of the available remote branches
129after the initial setup for a remote.
130+
131The named branches will be interpreted as if specified with the
Junio C Hamanocba446b2020-10-09 15:51:15132`-t` option on the `git remote add` command line.
Junio C Hamanof5de4cf2010-06-19 00:33:17133+
134With `--add`, instead of replacing the list of currently tracked
135branches, adds to that list.
136
Junio C Hamano1eb56092015-10-05 20:39:53137'get-url'::
138
139Retrieves 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 Hamano92d80372016-07-13 22:00:05142With `--push`, push URLs are queried rather than fetch URLs.
Junio C Hamano1eb56092015-10-05 20:39:53143+
Junio C Hamano92d80372016-07-13 22:00:05144With `--all`, all URLs for the remote will be listed.
Junio C Hamano1eb56092015-10-05 20:39:53145
Junio C Hamano57827fb2010-01-23 03:02:50146'set-url'::
147
Junio C Hamanoc3550302015-02-18 22:34:11148Changes URLs for the remote. Sets first URL for remote <name> that matches
Junio C Hamano57827fb2010-01-23 03:02:50149regex <oldurl> (first URL if no <oldurl> is given) to <newurl>. If
Junio C Hamanoc3550302015-02-18 22:34:11150<oldurl> doesn't match any URL, an error occurs and nothing is changed.
Junio C Hamano57827fb2010-01-23 03:02:50151+
Junio C Hamano92d80372016-07-13 22:00:05152With `--push`, push URLs are manipulated instead of fetch URLs.
Junio C Hamano57827fb2010-01-23 03:02:50153+
Junio C Hamano92d80372016-07-13 22:00:05154With `--add`, instead of changing existing URLs, new URL is added.
Junio C Hamano57827fb2010-01-23 03:02:50155+
Junio C Hamano92d80372016-07-13 22:00:05156With `--delete`, instead of changing existing URLs, all URLs matching
Junio C Hamano59a32b02021-12-10 22:53:38157regex <URL> are deleted for remote <name>. Trying to delete all
Junio C Hamanoc3550302015-02-18 22:34:11158non-push URLs is an error.
159+
160Note that the push URL and the fetch URL, even though they can
161be set differently, must still refer to the same place. What you
162pushed to the push URL should be what you would see if you
163immediately fetched from the fetch URL. If you are trying to
164fetch from one place (e.g. your upstream) and push to another (e.g.
165your publishing repository), use two separate remotes.
166
Junio C Hamano57827fb2010-01-23 03:02:50167
Junio C Hamanoee1e4282007-02-04 08:32:04168'show'::
Junio C Hamano1d3a6c72007-01-09 11:13:47169
Junio C Hamanoee1e4282007-02-04 08:32:04170Gives some information about the remote <name>.
Junio C Hamano401939f2007-07-01 06:34:30171+
172With `-n` option, the remote heads are not queried first with
173`git ls-remote <name>`; cached information is used instead.
Junio C Hamanoee1e4282007-02-04 08:32:04174
175'prune'::
176
Junio C Hamano664750f2018-03-06 23:25:44177Deletes stale references associated with <name>. By default, stale
178remote-tracking branches under <name> are deleted, but depending on
179global configuration and the configuration of the remote we might even
180prune local tags that haven't been pushed there. Equivalent to `git
181fetch --prune <name>`, except that no new references will be fetched.
182+
183See the PRUNING section of linkgit:git-fetch[1] for what it'll prune
184depending on various configuration.
Junio C Hamano401939f2007-07-01 06:34:30185+
Junio C Hamanocba446b2020-10-09 15:51:15186With `--dry-run` option, report what branches would be pruned, but do not
Junio C Hamano6fb124c2008-06-13 10:04:01187actually prune them.
Junio C Hamano0bbd4672007-02-20 04:52:14188
189'update'::
190
Junio C Hamano4dca9032018-06-04 13:49:31191Fetch updates for remotes or remote groups in the repository as defined by
Junio C Hamanocba446b2020-10-09 15:51:15192`remotes.<group>`. If neither group nor remote is specified on the command line,
Junio C Hamano9f883862009-08-11 06:23:52193the configuration parameter remotes.default will be used; if
Junio C Hamano361c1332007-11-14 12:17:22194remotes.default is not defined, all remotes which do not have the
Junio C Hamanocba446b2020-10-09 15:51:15195configuration parameter `remote.<name>.skipDefaultUpdate` set to true will
Junio C Hamano35738e82008-01-07 07:55:46196be updated. (See linkgit:git-config[1]).
Junio C Hamano98e32c32009-04-13 02:39:53197+
Junio C Hamano664750f2018-03-06 23:25:44198With `--prune` option, run pruning against all the remotes that are updated.
Junio C Hamano39381a72007-02-02 07:35:15199
Junio C Hamanoee1e4282007-02-04 08:32:04200
201DISCUSSION
202----------
203
Junio C Hamano1d3a6c72007-01-09 11:13:47204The remote configuration is achieved using the `remote.origin.url` and
205`remote.origin.fetch` configuration variables. (See
Junio C Hamano35738e82008-01-07 07:55:46206linkgit:git-config[1]).
Junio C Hamano1d3a6c72007-01-09 11:13:47207
Junio C Hamanoa65c1f42020-11-09 22:50:11208EXIT STATUS
209-----------
210
211On success, the exit status is `0`.
212
213When subcommands such as 'add', 'rename', and 'remove' can't find the
214remote in question, the exit status is `2`. When the remote already
215exists, the exit status is `3`.
216
217On any other error, the exit status may be any other non-zero value.
218
Junio C Hamanob9d9d902018-05-23 07:07:42219EXAMPLES
Junio C Hamano1d3a6c72007-01-09 11:13:47220--------
221
Junio C Hamano6ac2f142007-03-01 01:24:56222* Add a new remote, fetch, and check out a branch from it
223+
Junio C Hamano1d3a6c72007-01-09 11:13:47224------------
225$ git remote
226origin
227$ git branch -r
Junio C Hamanoa1952302013-07-01 21:31:18228 origin/HEAD -> origin/master
229 origin/master
230$ git remote add staging git://git.kernel.org/.../gregkh/staging.git
Junio C Hamano1d3a6c72007-01-09 11:13:47231$ git remote
Junio C Hamano1d3a6c72007-01-09 11:13:47232origin
Junio C Hamanoa1952302013-07-01 21:31:18233staging
234$ git fetch staging
235...
236From 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 Hamano1d3a6c72007-01-09 11:13:47240$ git branch -r
Junio C Hamanoa1952302013-07-01 21:31:18241 origin/HEAD -> origin/master
242 origin/master
243 staging/master
244 staging/staging-linus
245 staging/staging-next
Junio C Hamanoc9f11c22019-07-10 02:54:04246$ git switch -c staging staging/master
Junio C Hamano1d3a6c72007-01-09 11:13:47247...
248------------
249
Junio C Hamano1aa40d22010-01-21 17:46:43250* Imitate 'git clone' but track only selected branches
Junio C Hamano6ac2f142007-03-01 01:24:56251+
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 Hamano9049d912008-05-29 02:09:50261SEE ALSO
Junio C Hamano1d3a6c72007-01-09 11:13:47262--------
Junio C Hamano35738e82008-01-07 07:55:46263linkgit:git-fetch[1]
264linkgit:git-branch[1]
265linkgit:git-config[1]
Junio C Hamano1d3a6c72007-01-09 11:13:47266
Junio C Hamano1d3a6c72007-01-09 11:13:47267GIT
268---
Junio C Hamanof7c042d2008-06-06 22:50:53269Part of the linkgit:git[1] suite