]>
Commit | Line | Data |
---|---|---|
041e69c9 | 1 | git-remote(1) |
142d035a | 2 | ============= |
041e69c9 BF |
3 | |
4 | NAME | |
5 | ---- | |
a2f69581 | 6 | git-remote - Manage set of tracked repositories |
041e69c9 BF |
7 | |
8 | ||
9 | SYNOPSIS | |
10 | -------- | |
11 | [verse] | |
b1889c36 | 12 | 'git remote' [-v | --verbose] |
0460ed2c | 13 | 'git remote add' [-t <branch>] [-m <master>] [-f] [--[no-]tags] [--mirror=<fetch|push>] <name> <url> |
bf98421a | 14 | 'git remote rename' <old> <new> |
e17dba8f | 15 | 'git remote remove' <name> |
159543e8 | 16 | 'git remote set-head' <name> (-a | --auto | -d | --delete | <branch>) |
ca5bc9e6 | 17 | 'git remote set-branches' [--add] <name> <branch>... |
96f78d39 | 18 | 'git remote get-url' [--push] [--all] <name> |
433f2be1 IL |
19 | '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> | |
b17dd3f9 TR |
22 | 'git remote' [-v | --verbose] 'show' [-n] <name>... |
23 | 'git remote prune' [-n | --dry-run] <name>... | |
0adda936 | 24 | 'git remote' [-v | --verbose] 'update' [-p | --prune] [(<group> | <remote>)...] |
041e69c9 BF |
25 | |
26 | DESCRIPTION | |
27 | ----------- | |
28 | ||
29 | Manage the set of repositories ("remotes") whose branches you track. | |
30 | ||
041e69c9 | 31 | |
459cf2e9 SB |
32 | OPTIONS |
33 | ------- | |
34 | ||
35 | -v:: | |
36 | --verbose:: | |
37 | Be a little more verbose and show remote url after name. | |
4504107d | 38 | NOTE: This must be placed between `remote` and `subcommand`. |
459cf2e9 SB |
39 | |
40 | ||
0f390875 SP |
41 | COMMANDS |
42 | -------- | |
43 | ||
44 | With no arguments, shows a list of existing remotes. Several | |
45 | subcommands are available to perform operations on the remotes. | |
46 | ||
47 | 'add':: | |
48 | ||
49 | Adds a remote named <name> for the repository at | |
041e69c9 BF |
50 | <url>. The command `git fetch <name>` can then be used to create and |
51 | update remote-tracking branches <name>/<branch>. | |
c5ddca1f JH |
52 | + |
53 | With `-f` option, `git fetch <name>` is run immediately after | |
54 | the remote information is set up. | |
55 | + | |
111fb858 ST |
56 | With `--tags` option, `git fetch <name>` imports every tag from the |
57 | remote repository. | |
58 | + | |
59 | With `--no-tags` option, `git fetch <name>` does not import tags from | |
60 | the remote repository. | |
61 | + | |
aaba0ab4 MG |
62 | By default, only tags on fetched branches are imported |
63 | (see linkgit:git-fetch[1]). | |
64 | + | |
c5ddca1f JH |
65 | With `-t <branch>` option, instead of the default glob |
66 | refspec for the remote to track all branches under | |
0aceb220 | 67 | the `refs/remotes/<name>/` namespace, a refspec to track only `<branch>` |
c5ddca1f | 68 | is created. You can give more than one `-t <branch>` to track |
cf593cc4 | 69 | multiple branches without grabbing all branches. |
c5ddca1f | 70 | + |
0aceb220 | 71 | With `-m <master>` option, a symbolic-ref `refs/remotes/<name>/HEAD` is set |
bc14fac8 | 72 | up to point at remote's `<master>` branch. See also the set-head command. |
38944390 | 73 | + |
6cf378f0 | 74 | When a fetch mirror is created with `--mirror=fetch`, the refs will not |
a9f5a355 JK |
75 | be stored in the 'refs/remotes/' namespace, but rather everything in |
76 | 'refs/' on the remote will be directly mirrored into 'refs/' in the | |
77 | local repository. This option only makes sense in bare repositories, | |
78 | because a fetch would overwrite any local commits. | |
79 | + | |
6cf378f0 JK |
80 | When a push mirror is created with `--mirror=push`, then `git push` |
81 | will always behave as if `--mirror` was passed. | |
041e69c9 | 82 | |
bf98421a MV |
83 | 'rename':: |
84 | ||
0e615b25 | 85 | Rename the remote named <old> to <new>. All remote-tracking branches and |
bf98421a | 86 | configuration settings for the remote are updated. |
74443f18 MV |
87 | + |
88 | In 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 | |
90 | the configuration file format. | |
bf98421a | 91 | |
e17dba8f | 92 | 'remove':: |
1b4cbb5d JB |
93 | 'rm':: |
94 | ||
0e615b25 | 95 | Remove the remote named <name>. All remote-tracking branches and |
1b4cbb5d JB |
96 | configuration settings for the remote are removed. |
97 | ||
bc14fac8 JS |
98 | 'set-head':: |
99 | ||
0aceb220 JH |
100 | Sets or deletes the default branch (i.e. the target of the |
101 | symbolic-ref `refs/remotes/<name>/HEAD`) for | |
bc14fac8 JS |
102 | the named remote. Having a default branch for a remote is not required, |
103 | but allows the name of the remote to be specified in lieu of a specific | |
104 | branch. For example, if the default branch for `origin` is set to | |
105 | `master`, then `origin` may be specified wherever you would normally | |
106 | specify `origin/master`. | |
107 | + | |
159543e8 | 108 | With `-d` or `--delete`, the symbolic ref `refs/remotes/<name>/HEAD` is deleted. |
bc14fac8 | 109 | + |
159543e8 | 110 | With `-a` or `--auto`, the remote is queried to determine its `HEAD`, then the |
0aceb220 | 111 | symbolic-ref `refs/remotes/<name>/HEAD` is set to the same branch. e.g., if the remote |
bc14fac8 | 112 | `HEAD` is pointed at `next`, "`git remote set-head origin -a`" will set |
0aceb220 | 113 | the symbolic-ref `refs/remotes/origin/HEAD` to `refs/remotes/origin/next`. This will |
bc14fac8 JS |
114 | only work if `refs/remotes/origin/next` already exists; if not it must be |
115 | fetched first. | |
116 | + | |
0aceb220 JH |
117 | Use `<branch>` to set the symbolic-ref `refs/remotes/<name>/HEAD` explicitly. e.g., "git |
118 | remote set-head origin master" will set the symbolic-ref `refs/remotes/origin/HEAD` to | |
bc14fac8 JS |
119 | `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 | ||
3d8b6949 JN |
123 | 'set-branches':: |
124 | ||
125 | Changes the list of branches tracked by the named remote. | |
126 | This can be used to track a subset of the available remote branches | |
127 | after the initial setup for a remote. | |
128 | + | |
129 | The named branches will be interpreted as if specified with the | |
130 | `-t` option on the 'git remote add' command line. | |
131 | + | |
132 | With `--add`, instead of replacing the list of currently tracked | |
133 | branches, adds to that list. | |
134 | ||
96f78d39 BB |
135 | 'get-url':: |
136 | ||
137 | Retrieves the URLs for a remote. Configurations for `insteadOf` and | |
138 | `pushInsteadOf` are expanded here. By default, only the first URL is listed. | |
139 | + | |
bcf9626a | 140 | With `--push`, push URLs are queried rather than fetch URLs. |
96f78d39 | 141 | + |
bcf9626a | 142 | With `--all`, all URLs for the remote will be listed. |
96f78d39 | 143 | |
433f2be1 IL |
144 | 'set-url':: |
145 | ||
697f6528 | 146 | Changes URLs for the remote. Sets first URL for remote <name> that matches |
433f2be1 | 147 | regex <oldurl> (first URL if no <oldurl> is given) to <newurl>. If |
697f6528 | 148 | <oldurl> doesn't match any URL, an error occurs and nothing is changed. |
433f2be1 | 149 | + |
bcf9626a | 150 | With `--push`, push URLs are manipulated instead of fetch URLs. |
433f2be1 | 151 | + |
bcf9626a | 152 | With `--add`, instead of changing existing URLs, new URL is added. |
433f2be1 | 153 | + |
bcf9626a | 154 | With `--delete`, instead of changing existing URLs, all URLs matching |
697f6528 JH |
155 | regex <url> are deleted for remote <name>. Trying to delete all |
156 | non-push URLs is an error. | |
157 | + | |
158 | Note that the push URL and the fetch URL, even though they can | |
159 | be set differently, must still refer to the same place. What you | |
160 | pushed to the push URL should be what you would see if you | |
161 | immediately fetched from the fetch URL. If you are trying to | |
162 | fetch from one place (e.g. your upstream) and push to another (e.g. | |
163 | your publishing repository), use two separate remotes. | |
164 | ||
433f2be1 | 165 | |
0f390875 | 166 | 'show':: |
041e69c9 | 167 | |
0f390875 | 168 | Gives some information about the remote <name>. |
181ea688 SV |
169 | + |
170 | With `-n` option, the remote heads are not queried first with | |
171 | `git ls-remote <name>`; cached information is used instead. | |
0f390875 SP |
172 | |
173 | 'prune':: | |
174 | ||
d0e07472 ÆAB |
175 | Deletes stale references associated with <name>. By default, stale |
176 | remote-tracking branches under <name> are deleted, but depending on | |
177 | global configuration and the configuration of the remote we might even | |
178 | prune local tags that haven't been pushed there. Equivalent to `git | |
179 | fetch --prune <name>`, except that no new references will be fetched. | |
180 | + | |
181 | See the PRUNING section of linkgit:git-fetch[1] for what it'll prune | |
182 | depending on various configuration. | |
181ea688 | 183 | + |
75f492ac | 184 | With `--dry-run` option, report what branches will be pruned, but do not |
8d767927 | 185 | actually prune them. |
1e592d65 TT |
186 | |
187 | 'update':: | |
188 | ||
86f0b372 | 189 | Fetch updates for remotes or remote groups in the repository as defined by |
a97447a4 | 190 | remotes.<group>. If neither group nor remote is specified on the command line, |
75f492ac | 191 | the configuration parameter remotes.default will be used; if |
cb5c49b9 | 192 | remotes.default is not defined, all remotes which do not have the |
1918278e | 193 | configuration parameter remote.<name>.skipDefaultUpdate set to true will |
5162e697 | 194 | be updated. (See linkgit:git-config[1]). |
efa54803 | 195 | + |
d0e07472 | 196 | With `--prune` option, run pruning against all the remotes that are updated. |
859607df | 197 | |
0f390875 SP |
198 | |
199 | DISCUSSION | |
200 | ---------- | |
201 | ||
041e69c9 BF |
202 | The remote configuration is achieved using the `remote.origin.url` and |
203 | `remote.origin.fetch` configuration variables. (See | |
5162e697 | 204 | linkgit:git-config[1]). |
041e69c9 | 205 | |
76a8788c | 206 | EXAMPLES |
041e69c9 BF |
207 | -------- |
208 | ||
db554bf0 JH |
209 | * Add a new remote, fetch, and check out a branch from it |
210 | + | |
041e69c9 BF |
211 | ------------ |
212 | $ git remote | |
213 | origin | |
214 | $ git branch -r | |
34a25d4c TK |
215 | origin/HEAD -> origin/master |
216 | origin/master | |
217 | $ git remote add staging git://git.kernel.org/.../gregkh/staging.git | |
041e69c9 | 218 | $ git remote |
041e69c9 | 219 | origin |
34a25d4c TK |
220 | staging |
221 | $ git fetch staging | |
222 | ... | |
223 | From git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging | |
224 | * [new branch] master -> staging/master | |
225 | * [new branch] staging-linus -> staging/staging-linus | |
226 | * [new branch] staging-next -> staging/staging-next | |
041e69c9 | 227 | $ git branch -r |
34a25d4c TK |
228 | origin/HEAD -> origin/master |
229 | origin/master | |
230 | staging/master | |
231 | staging/staging-linus | |
232 | staging/staging-next | |
233 | $ git checkout -b staging staging/master | |
041e69c9 BF |
234 | ... |
235 | ------------ | |
236 | ||
0b444cdb | 237 | * Imitate 'git clone' but track only selected branches |
db554bf0 JH |
238 | + |
239 | ------------ | |
240 | $ mkdir project.git | |
241 | $ cd project.git | |
242 | $ git init | |
243 | $ git remote add -f -t master -m master origin git://example.com/git.git/ | |
244 | $ git merge origin | |
245 | ------------ | |
246 | ||
247 | ||
56ae8df5 | 248 | SEE ALSO |
041e69c9 | 249 | -------- |
5162e697 DM |
250 | linkgit:git-fetch[1] |
251 | linkgit:git-branch[1] | |
252 | linkgit:git-config[1] | |
041e69c9 | 253 | |
041e69c9 BF |
254 | GIT |
255 | --- | |
9e1f0a85 | 256 | Part of the linkgit:git[1] suite |