interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / Documentation / git-remote.adoc

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