blob: 31c29c9b31b202eeba1fbb2fe0d31054d46d4882 [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 Hamanocba446b2020-10-09 15:51:1513'git remote add' [-t <branch>] [-m <master>] [-f] [--[no-]tags] [--mirror=(fetch|push)] <name> <url>
Junio C Hamano28363492008-11-14 08:26:3114'git remote rename' <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>
21'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 Hamanocba446b2020-10-09 15:51:1538NOTE: This must be placed between `remote` and subcommand.
Junio C Hamanoeb415992008-06-08 22:49:4739
40
Junio C Hamanoee1e4282007-02-04 08:32:0441COMMANDS
42--------
43
44With no arguments, shows a list of existing remotes. Several
45subcommands are available to perform operations on the remotes.
46
47'add'::
48
Junio C Hamanocba446b2020-10-09 15:51:1549Add a remote named <name> for the repository at
Junio C Hamano1d3a6c72007-01-09 11:13:4750<url>. The command `git fetch <name>` can then be used to create and
51update remote-tracking branches <name>/<branch>.
Junio C Hamano17dde0e2007-02-26 09:50:2152+
53With `-f` option, `git fetch <name>` is run immediately after
54the remote information is set up.
55+
Junio C Hamanocc7636a2010-05-21 14:57:5356With `--tags` option, `git fetch <name>` imports every tag from the
57remote repository.
58+
59With `--no-tags` option, `git fetch <name>` does not import tags from
60the remote repository.
61+
Junio C Hamano6bf68cf2015-03-06 23:46:2962By default, only tags on fetched branches are imported
63(see linkgit:git-fetch[1]).
64+
Junio C Hamano17dde0e2007-02-26 09:50:2165With `-t <branch>` option, instead of the default glob
66refspec for the remote to track all branches under
Junio C Hamano360e3a12011-07-13 23:51:5667the `refs/remotes/<name>/` namespace, a refspec to track only `<branch>`
Junio C Hamano17dde0e2007-02-26 09:50:2168is created. You can give more than one `-t <branch>` to track
Junio C Hamano67fad6d2007-05-06 08:53:1269multiple branches without grabbing all branches.
Junio C Hamano17dde0e2007-02-26 09:50:2170+
Junio C Hamano360e3a12011-07-13 23:51:5671With `-m <master>` option, a symbolic-ref `refs/remotes/<name>/HEAD` is set
Junio C Hamanod257cff2009-03-18 05:27:1672up to point at remote's `<master>` branch. See also the set-head command.
Junio C Hamano58155b42007-09-15 07:46:1473+
Junio C Hamanob76a6862012-05-02 22:02:4674When a fetch mirror is created with `--mirror=fetch`, the refs will not
Junio C Hamanoee3adc32011-04-06 19:53:3875be stored in the 'refs/remotes/' namespace, but rather everything in
76'refs/' on the remote will be directly mirrored into 'refs/' in the
77local repository. This option only makes sense in bare repositories,
78because a fetch would overwrite any local commits.
79+
Junio C Hamanob76a6862012-05-02 22:02:4680When a push mirror is created with `--mirror=push`, then `git push`
81will always behave as if `--mirror` was passed.
Junio C Hamano1d3a6c72007-01-09 11:13:4782
Junio C Hamano28363492008-11-14 08:26:3183'rename'::
84
Junio C Hamano97bcb482010-11-25 03:16:0785Rename the remote named <old> to <new>. All remote-tracking branches and
Junio C Hamano28363492008-11-14 08:26:3186configuration settings for the remote are updated.
87+
88In case <old> and <new> are the same, and <old> is a file under
89`$GIT_DIR/remotes` or `$GIT_DIR/branches`, the remote is converted to
90the configuration file format.
91
Junio C Hamano693e7092012-09-12 22:56:5392'remove'::
Junio C Hamano4fd58d42007-09-30 00:51:1493'rm'::
94
Junio C Hamano97bcb482010-11-25 03:16:0795Remove the remote named <name>. All remote-tracking branches and
Junio C Hamano4fd58d42007-09-30 00:51:1496configuration settings for the remote are removed.
97
Junio C Hamanod257cff2009-03-18 05:27:1698'set-head'::
99
Junio C Hamano360e3a12011-07-13 23:51:56100Sets or deletes the default branch (i.e. the target of the
101symbolic-ref `refs/remotes/<name>/HEAD`) for
Junio C Hamanod257cff2009-03-18 05:27:16102the named remote. Having a default branch for a remote is not required,
103but allows the name of the remote to be specified in lieu of a specific
104branch. For example, if the default branch for `origin` is set to
105`master`, then `origin` may be specified wherever you would normally
106specify `origin/master`.
107+
Junio C Hamano369e3402013-10-15 18:40:25108With `-d` or `--delete`, the symbolic ref `refs/remotes/<name>/HEAD` is deleted.
Junio C Hamanod257cff2009-03-18 05:27:16109+
Junio C Hamano369e3402013-10-15 18:40:25110With `-a` or `--auto`, the remote is queried to determine its `HEAD`, then the
Junio C Hamano360e3a12011-07-13 23:51:56111symbolic-ref `refs/remotes/<name>/HEAD` is set to the same branch. e.g., if the remote
Junio C Hamanocba446b2020-10-09 15:51:15112`HEAD` is pointed at `next`, `git remote set-head origin -a` will set
Junio C Hamano360e3a12011-07-13 23:51:56113the symbolic-ref `refs/remotes/origin/HEAD` to `refs/remotes/origin/next`. This will
Junio C Hamanod257cff2009-03-18 05:27:16114only work if `refs/remotes/origin/next` already exists; if not it must be
115fetched first.
116+
Junio C Hamanocba446b2020-10-09 15:51:15117Use `<branch>` to set the symbolic-ref `refs/remotes/<name>/HEAD` explicitly. e.g., `git
118remote set-head origin master` will set the symbolic-ref `refs/remotes/origin/HEAD` to
Junio C Hamanod257cff2009-03-18 05:27:16119`refs/remotes/origin/master`. This will only work if
120`refs/remotes/origin/master` already exists; if not it must be fetched first.
121+
122
Junio C Hamanof5de4cf2010-06-19 00:33:17123'set-branches'::
124
125Changes the list of branches tracked by the named remote.
126This can be used to track a subset of the available remote branches
127after the initial setup for a remote.
128+
129The named branches will be interpreted as if specified with the
Junio C Hamanocba446b2020-10-09 15:51:15130`-t` option on the `git remote add` command line.
Junio C Hamanof5de4cf2010-06-19 00:33:17131+
132With `--add`, instead of replacing the list of currently tracked
133branches, adds to that list.
134
Junio C Hamano1eb56092015-10-05 20:39:53135'get-url'::
136
137Retrieves the URLs for a remote. Configurations for `insteadOf` and
138`pushInsteadOf` are expanded here. By default, only the first URL is listed.
139+
Junio C Hamano92d80372016-07-13 22:00:05140With `--push`, push URLs are queried rather than fetch URLs.
Junio C Hamano1eb56092015-10-05 20:39:53141+
Junio C Hamano92d80372016-07-13 22:00:05142With `--all`, all URLs for the remote will be listed.
Junio C Hamano1eb56092015-10-05 20:39:53143
Junio C Hamano57827fb2010-01-23 03:02:50144'set-url'::
145
Junio C Hamanoc3550302015-02-18 22:34:11146Changes URLs for the remote. Sets first URL for remote <name> that matches
Junio C Hamano57827fb2010-01-23 03:02:50147regex <oldurl> (first URL if no <oldurl> is given) to <newurl>. If
Junio C Hamanoc3550302015-02-18 22:34:11148<oldurl> doesn't match any URL, an error occurs and nothing is changed.
Junio C Hamano57827fb2010-01-23 03:02:50149+
Junio C Hamano92d80372016-07-13 22:00:05150With `--push`, push URLs are manipulated instead of fetch URLs.
Junio C Hamano57827fb2010-01-23 03:02:50151+
Junio C Hamano92d80372016-07-13 22:00:05152With `--add`, instead of changing existing URLs, new URL is added.
Junio C Hamano57827fb2010-01-23 03:02:50153+
Junio C Hamano92d80372016-07-13 22:00:05154With `--delete`, instead of changing existing URLs, all URLs matching
Junio C Hamanoc3550302015-02-18 22:34:11155regex <url> are deleted for remote <name>. Trying to delete all
156non-push URLs is an error.
157+
158Note that the push URL and the fetch URL, even though they can
159be set differently, must still refer to the same place. What you
160pushed to the push URL should be what you would see if you
161immediately fetched from the fetch URL. If you are trying to
162fetch from one place (e.g. your upstream) and push to another (e.g.
163your publishing repository), use two separate remotes.
164
Junio C Hamano57827fb2010-01-23 03:02:50165
Junio C Hamanoee1e4282007-02-04 08:32:04166'show'::
Junio C Hamano1d3a6c72007-01-09 11:13:47167
Junio C Hamanoee1e4282007-02-04 08:32:04168Gives some information about the remote <name>.
Junio C Hamano401939f2007-07-01 06:34:30169+
170With `-n` option, the remote heads are not queried first with
171`git ls-remote <name>`; cached information is used instead.
Junio C Hamanoee1e4282007-02-04 08:32:04172
173'prune'::
174
Junio C Hamano664750f2018-03-06 23:25:44175Deletes stale references associated with <name>. By default, stale
176remote-tracking branches under <name> are deleted, but depending on
177global configuration and the configuration of the remote we might even
178prune local tags that haven't been pushed there. Equivalent to `git
179fetch --prune <name>`, except that no new references will be fetched.
180+
181See the PRUNING section of linkgit:git-fetch[1] for what it'll prune
182depending on various configuration.
Junio C Hamano401939f2007-07-01 06:34:30183+
Junio C Hamanocba446b2020-10-09 15:51:15184With `--dry-run` option, report what branches would be pruned, but do not
Junio C Hamano6fb124c2008-06-13 10:04:01185actually prune them.
Junio C Hamano0bbd4672007-02-20 04:52:14186
187'update'::
188
Junio C Hamano4dca9032018-06-04 13:49:31189Fetch updates for remotes or remote groups in the repository as defined by
Junio C Hamanocba446b2020-10-09 15:51:15190`remotes.<group>`. If neither group nor remote is specified on the command line,
Junio C Hamano9f883862009-08-11 06:23:52191the configuration parameter remotes.default will be used; if
Junio C Hamano361c1332007-11-14 12:17:22192remotes.default is not defined, all remotes which do not have the
Junio C Hamanocba446b2020-10-09 15:51:15193configuration parameter `remote.<name>.skipDefaultUpdate` set to true will
Junio C Hamano35738e82008-01-07 07:55:46194be updated. (See linkgit:git-config[1]).
Junio C Hamano98e32c32009-04-13 02:39:53195+
Junio C Hamano664750f2018-03-06 23:25:44196With `--prune` option, run pruning against all the remotes that are updated.
Junio C Hamano39381a72007-02-02 07:35:15197
Junio C Hamanoee1e4282007-02-04 08:32:04198
199DISCUSSION
200----------
201
Junio C Hamano1d3a6c72007-01-09 11:13:47202The remote configuration is achieved using the `remote.origin.url` and
203`remote.origin.fetch` configuration variables. (See
Junio C Hamano35738e82008-01-07 07:55:46204linkgit:git-config[1]).
Junio C Hamano1d3a6c72007-01-09 11:13:47205
Junio C Hamanoa65c1f42020-11-09 22:50:11206EXIT STATUS
207-----------
208
209On success, the exit status is `0`.
210
211When subcommands such as 'add', 'rename', and 'remove' can't find the
212remote in question, the exit status is `2`. When the remote already
213exists, the exit status is `3`.
214
215On any other error, the exit status may be any other non-zero value.
216
Junio C Hamanob9d9d902018-05-23 07:07:42217EXAMPLES
Junio C Hamano1d3a6c72007-01-09 11:13:47218--------
219
Junio C Hamano6ac2f142007-03-01 01:24:56220* Add a new remote, fetch, and check out a branch from it
221+
Junio C Hamano1d3a6c72007-01-09 11:13:47222------------
223$ git remote
224origin
225$ git branch -r
Junio C Hamanoa1952302013-07-01 21:31:18226 origin/HEAD -> origin/master
227 origin/master
228$ git remote add staging git://git.kernel.org/.../gregkh/staging.git
Junio C Hamano1d3a6c72007-01-09 11:13:47229$ git remote
Junio C Hamano1d3a6c72007-01-09 11:13:47230origin
Junio C Hamanoa1952302013-07-01 21:31:18231staging
232$ git fetch staging
233...
234From git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
235 * [new branch] master -> staging/master
236 * [new branch] staging-linus -> staging/staging-linus
237 * [new branch] staging-next -> staging/staging-next
Junio C Hamano1d3a6c72007-01-09 11:13:47238$ git branch -r
Junio C Hamanoa1952302013-07-01 21:31:18239 origin/HEAD -> origin/master
240 origin/master
241 staging/master
242 staging/staging-linus
243 staging/staging-next
Junio C Hamanoc9f11c22019-07-10 02:54:04244$ git switch -c staging staging/master
Junio C Hamano1d3a6c72007-01-09 11:13:47245...
246------------
247
Junio C Hamano1aa40d22010-01-21 17:46:43248* Imitate 'git clone' but track only selected branches
Junio C Hamano6ac2f142007-03-01 01:24:56249+
250------------
251$ mkdir project.git
252$ cd project.git
253$ git init
254$ git remote add -f -t master -m master origin git://example.com/git.git/
255$ git merge origin
256------------
257
258
Junio C Hamano9049d912008-05-29 02:09:50259SEE ALSO
Junio C Hamano1d3a6c72007-01-09 11:13:47260--------
Junio C Hamano35738e82008-01-07 07:55:46261linkgit:git-fetch[1]
262linkgit:git-branch[1]
263linkgit:git-config[1]
Junio C Hamano1d3a6c72007-01-09 11:13:47264
Junio C Hamano1d3a6c72007-01-09 11:13:47265GIT
266---
Junio C Hamanof7c042d2008-06-06 22:50:53267Part of the linkgit:git[1] suite