updated git doc
[TortoiseGit.git] / doc / source / en / TortoiseGit / git_doc / git-push.xml
blobfb31c35b87b89063e2253b8a9a3f2327358cd03a
1 <?xml version="1.0" encoding="UTF-8"?>\r
2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">\r
3 \r
4 <article lang="en" id="git-push(1)">\r
5 <articleinfo>\r
6     <title>git-push(1)</title>\r
7 <indexterm>\r
8 <primary>git-push(1)</primary>\r
9 </indexterm>\r
10 </articleinfo>\r
11 <simplesect id="_name">\r
12 <title>NAME</title>\r
13 <simpara>git-push - Update remote refs along with associated objects</simpara>\r
14 </simplesect>\r
15 <simplesect id="_synopsis">\r
16 <title>SYNOPSIS</title>\r
17 <blockquote>\r
18 <literallayout><emphasis>git push</emphasis> [--all | --mirror | --tags] [-n | --dry-run] [--receive-pack=&lt;git-receive-pack&gt;]\r
19            [--repo=&lt;repository&gt;] [-f | --force] [--prune] [-v | --verbose] [-u | --set-upstream]\r
20            [&lt;repository&gt; [&lt;refspec&gt;&#8230;]]</literallayout>\r
21 </blockquote>\r
22 </simplesect>\r
23 <simplesect id="_description">\r
24 <title>DESCRIPTION</title>\r
25 <simpara>Updates remote refs using local refs, while sending objects\r
26 necessary to complete the given refs.</simpara>\r
27 <simpara>You can make interesting things happen to a repository\r
28 every time you push into it, by setting up <emphasis>hooks</emphasis> there.  See\r
29 documentation for <xref linkend="git-receive-pack(1)" />.</simpara>\r
30 </simplesect>\r
31 <simplesect id="_options_anchor_id_options_xreflabel_options">\r
32 <title>OPTIONS<anchor id="OPTIONS" xreflabel="[OPTIONS]"/></title>\r
33 <variablelist>\r
34 <varlistentry>\r
35 <term>\r
36 &lt;repository&gt;\r
37 </term>\r
38 <listitem>\r
39 <simpara>\r
40         The "remote" repository that is destination of a push\r
41         operation.  This parameter can be either a URL\r
42         (see the section <link linkend="URLS">GIT URLS</link> below) or the name\r
43         of a remote (see the section <link linkend="REMOTES">REMOTES</link> below).\r
44 </simpara>\r
45 </listitem>\r
46 </varlistentry>\r
47 <varlistentry>\r
48 <term>\r
49 &lt;refspec&gt;&#8230;\r
50 </term>\r
51 <listitem>\r
52 <simpara>\r
53         The format of a &lt;refspec&gt; parameter is an optional plus\r
54         <emphasis>+</emphasis>, followed by the source ref &lt;src&gt;, followed\r
55         by a colon <emphasis>:</emphasis>, followed by the destination ref &lt;dst&gt;.\r
56         It is used to specify with what &lt;src&gt; object the &lt;dst&gt; ref\r
57         in the remote repository is to be updated.\r
58 </simpara>\r
59 <simpara>The &lt;src&gt; is often the name of the branch you would want to push, but\r
60 it can be any arbitrary "SHA-1 expression", such as <emphasis>master~4</emphasis> or\r
61 <emphasis>HEAD</emphasis> (see <xref linkend="gitrevisions(7)" />).</simpara>\r
62 <simpara>The &lt;dst&gt; tells which ref on the remote side is updated with this\r
63 push. Arbitrary expressions cannot be used here, an actual ref must\r
64 be named. If <emphasis>:</emphasis>&lt;dst&gt; is omitted, the same ref as &lt;src&gt; will be\r
65 updated.</simpara>\r
66 <simpara>The object referenced by &lt;src&gt; is used to update the &lt;dst&gt; reference\r
67 on the remote side, but by default this is only allowed if the\r
68 update can fast-forward &lt;dst&gt;.  By having the optional leading <emphasis>+</emphasis>,\r
69 you can tell git to update the &lt;dst&gt; ref even when the update is not a\r
70 fast-forward.  This does <emphasis role="strong">not</emphasis> attempt to merge &lt;src&gt; into &lt;dst&gt;.  See\r
71 EXAMPLES below for details.</simpara>\r
72 <simpara><emphasis>tag &lt;tag&gt;</emphasis> means the same as <emphasis>refs/tags/&lt;tag&gt;:refs/tags/&lt;tag&gt;</emphasis>.</simpara>\r
73 <simpara>Pushing an empty &lt;src&gt; allows you to delete the &lt;dst&gt; ref from\r
74 the remote repository.</simpara>\r
75 <simpara>The special refspec <emphasis>:</emphasis> (or <emphasis>+:</emphasis> to allow non-fast-forward updates)\r
76 directs git to push "matching" branches: for every branch that exists on\r
77 the local side, the remote side is updated if a branch of the same name\r
78 already exists on the remote side.  This is the default operation mode\r
79 if no explicit refspec is found (that is neither on the command line\r
80 nor in any Push line of the corresponding remotes file---see below).</simpara>\r
81 </listitem>\r
82 </varlistentry>\r
83 <varlistentry>\r
84 <term>\r
85 --all\r
86 </term>\r
87 <listitem>\r
88 <simpara>\r
89         Instead of naming each ref to push, specifies that all\r
90         refs under <emphasis>refs/heads/</emphasis> be pushed.\r
91 </simpara>\r
92 </listitem>\r
93 </varlistentry>\r
94 <varlistentry>\r
95 <term>\r
96 --prune\r
97 </term>\r
98 <listitem>\r
99 <simpara>\r
100         Remove remote branches that don't have a local counterpart. For example\r
101         a remote branch <emphasis>tmp</emphasis> will be removed if a local branch with the same\r
102         name doesn't exist any more. This also respects refspecs, e.g.\r
103         <emphasis>git push --prune remote refs/heads/*:refs/tmp/*</emphasis> would\r
104         make sure that remote <emphasis>refs/tmp/foo</emphasis> will be removed if <emphasis>refs/heads/foo</emphasis>\r
105         doesn't exist.\r
106 </simpara>\r
107 </listitem>\r
108 </varlistentry>\r
109 <varlistentry>\r
110 <term>\r
111 --mirror\r
112 </term>\r
113 <listitem>\r
114 <simpara>\r
115         Instead of naming each ref to push, specifies that all\r
116         refs under <emphasis>refs/</emphasis> (which includes but is not\r
117         limited to <emphasis>refs/heads/</emphasis>, <emphasis>refs/remotes/</emphasis>, and <emphasis>refs/tags/</emphasis>)\r
118         be mirrored to the remote repository.  Newly created local\r
119         refs will be pushed to the remote end, locally updated refs\r
120         will be force updated on the remote end, and deleted refs\r
121         will be removed from the remote end.  This is the default\r
122         if the configuration option <emphasis>remote.&lt;remote&gt;.mirror</emphasis> is\r
123         set.\r
124 </simpara>\r
125 </listitem>\r
126 </varlistentry>\r
127 <varlistentry>\r
128 <term>\r
129 -n\r
130 </term>\r
131 <term>\r
132 --dry-run\r
133 </term>\r
134 <listitem>\r
135 <simpara>\r
136         Do everything except actually send the updates.\r
137 </simpara>\r
138 </listitem>\r
139 </varlistentry>\r
140 <varlistentry>\r
141 <term>\r
142 --porcelain\r
143 </term>\r
144 <listitem>\r
145 <simpara>\r
146         Produce machine-readable output.  The output status line for each ref\r
147         will be tab-separated and sent to stdout instead of stderr.  The full\r
148         symbolic names of the refs will be given.\r
149 </simpara>\r
150 </listitem>\r
151 </varlistentry>\r
152 <varlistentry>\r
153 <term>\r
154 --delete\r
155 </term>\r
156 <listitem>\r
157 <simpara>\r
158         All listed refs are deleted from the remote repository. This is\r
159         the same as prefixing all refs with a colon.\r
160 </simpara>\r
161 </listitem>\r
162 </varlistentry>\r
163 <varlistentry>\r
164 <term>\r
165 --tags\r
166 </term>\r
167 <listitem>\r
168 <simpara>\r
169         All refs under <emphasis>refs/tags</emphasis> are pushed, in\r
170         addition to refspecs explicitly listed on the command\r
171         line.\r
172 </simpara>\r
173 </listitem>\r
174 </varlistentry>\r
175 <varlistentry>\r
176 <term>\r
177 --receive-pack=&lt;git-receive-pack&gt;\r
178 </term>\r
179 <term>\r
180 --exec=&lt;git-receive-pack&gt;\r
181 </term>\r
182 <listitem>\r
183 <simpara>\r
184         Path to the <emphasis>git-receive-pack</emphasis> program on the remote\r
185         end.  Sometimes useful when pushing to a remote\r
186         repository over ssh, and you do not have the program in\r
187         a directory on the default $PATH.\r
188 </simpara>\r
189 </listitem>\r
190 </varlistentry>\r
191 <varlistentry>\r
192 <term>\r
193 -f\r
194 </term>\r
195 <term>\r
196 --force\r
197 </term>\r
198 <listitem>\r
199 <simpara>\r
200         Usually, the command refuses to update a remote ref that is\r
201         not an ancestor of the local ref used to overwrite it.\r
202         This flag disables the check.  This can cause the\r
203         remote repository to lose commits; use it with care.\r
204 </simpara>\r
205 </listitem>\r
206 </varlistentry>\r
207 <varlistentry>\r
208 <term>\r
209 --repo=&lt;repository&gt;\r
210 </term>\r
211 <listitem>\r
212 <simpara>\r
213         This option is only relevant if no &lt;repository&gt; argument is\r
214         passed in the invocation. In this case, <emphasis>git push</emphasis> derives the\r
215         remote name from the current branch: If it tracks a remote\r
216         branch, then that remote repository is pushed to. Otherwise,\r
217         the name "origin" is used. For this latter case, this option\r
218         can be used to override the name "origin". In other words,\r
219         the difference between these two commands\r
220 </simpara>\r
221 <screen>git push public         #1\r
222 git push --repo=public  #2</screen>\r
223 <simpara>is that #1 always pushes to "public" whereas #2 pushes to "public"\r
224 only if the current branch does not track a remote branch. This is\r
225 useful if you write an alias or script around <emphasis>git push</emphasis>.</simpara>\r
226 </listitem>\r
227 </varlistentry>\r
228 <varlistentry>\r
229 <term>\r
230 -u\r
231 </term>\r
232 <term>\r
233 --set-upstream\r
234 </term>\r
235 <listitem>\r
236 <simpara>\r
237         For every branch that is up to date or successfully pushed, add\r
238         upstream (tracking) reference, used by argument-less\r
239         <xref linkend="git-pull(1)" /> and other commands. For more information,\r
240         see <emphasis>branch.&lt;name&gt;.merge</emphasis> in <xref linkend="git-config(1)" />.\r
241 </simpara>\r
242 </listitem>\r
243 </varlistentry>\r
244 <varlistentry>\r
245 <term>\r
246 --thin\r
247 </term>\r
248 <term>\r
249 --no-thin\r
250 </term>\r
251 <listitem>\r
252 <simpara>\r
253         These options are passed to <xref linkend="git-send-pack(1)" />. A thin transfer\r
254         significantly reduces the amount of sent data when the sender and\r
255         receiver share many of the same objects in common. The default is\r
256         --thin.\r
257 </simpara>\r
258 </listitem>\r
259 </varlistentry>\r
260 <varlistentry>\r
261 <term>\r
262 -q\r
263 </term>\r
264 <term>\r
265 --quiet\r
266 </term>\r
267 <listitem>\r
268 <simpara>\r
269         Suppress all output, including the listing of updated refs,\r
270         unless an error occurs. Progress is not reported to the standard\r
271         error stream.\r
272 </simpara>\r
273 </listitem>\r
274 </varlistentry>\r
275 <varlistentry>\r
276 <term>\r
277 -v\r
278 </term>\r
279 <term>\r
280 --verbose\r
281 </term>\r
282 <listitem>\r
283 <simpara>\r
284         Run verbosely.\r
285 </simpara>\r
286 </listitem>\r
287 </varlistentry>\r
288 <varlistentry>\r
289 <term>\r
290 --progress\r
291 </term>\r
292 <listitem>\r
293 <simpara>\r
294         Progress status is reported on the standard error stream\r
295         by default when it is attached to a terminal, unless -q\r
296         is specified. This flag forces progress status even if the\r
297         standard error stream is not directed to a terminal.\r
298 </simpara>\r
299 </listitem>\r
300 </varlistentry>\r
301 <varlistentry>\r
302 <term>\r
303 --recurse-submodules=check\r
304 </term>\r
305 <listitem>\r
306 <simpara>\r
307         Check whether all submodule commits used by the revisions to be\r
308         pushed are available on a remote tracking branch. Otherwise the\r
309         push will be aborted and the command will exit with non-zero status.\r
310 </simpara>\r
311 </listitem>\r
312 </varlistentry>\r
313 </variablelist>\r
314 </simplesect>\r
315 <simplesect id="_git_urls_anchor_id_urls_xreflabel_urls">\r
316 <title>GIT URLS<anchor id="URLS" xreflabel="[URLS]"/></title>\r
317 <simpara>In general, URLs contain information about the transport protocol, the\r
318 address of the remote server, and the path to the repository.\r
319 Depending on the transport protocol, some of this information may be\r
320 absent.</simpara>\r
321 <simpara>Git natively supports ssh, git, http, https, ftp, ftps, and rsync\r
322 protocols. The following syntaxes may be used with them:</simpara>\r
323 <itemizedlist>\r
324 <listitem>\r
325 <simpara>\r
326 ssh://&#91;user@&#93;host.xz&#91;:port&#93;/path/to/repo.git/\r
327 </simpara>\r
328 </listitem>\r
329 <listitem>\r
330 <simpara>\r
331 git://host.xz&#91;:port&#93;/path/to/repo.git/\r
332 </simpara>\r
333 </listitem>\r
334 <listitem>\r
335 <simpara>\r
336 http&#91;s&#93;://host.xz&#91;:port&#93;/path/to/repo.git/\r
337 </simpara>\r
338 </listitem>\r
339 <listitem>\r
340 <simpara>\r
341 ftp&#91;s&#93;://host.xz&#91;:port&#93;/path/to/repo.git/\r
342 </simpara>\r
343 </listitem>\r
344 <listitem>\r
345 <simpara>\r
346 rsync://host.xz/path/to/repo.git/\r
347 </simpara>\r
348 </listitem>\r
349 </itemizedlist>\r
350 <simpara>An alternative scp-like syntax may also be used with the ssh protocol:</simpara>\r
351 <itemizedlist>\r
352 <listitem>\r
353 <simpara>\r
354 &#91;user@&#93;host.xz:path/to/repo.git/\r
355 </simpara>\r
356 </listitem>\r
357 </itemizedlist>\r
358 <simpara>The ssh and git protocols additionally support ~username expansion:</simpara>\r
359 <itemizedlist>\r
360 <listitem>\r
361 <simpara>\r
362 ssh://&#91;user@&#93;host.xz&#91;:port&#93;/~&#91;user&#93;/path/to/repo.git/\r
363 </simpara>\r
364 </listitem>\r
365 <listitem>\r
366 <simpara>\r
367 git://host.xz&#91;:port&#93;/~&#91;user&#93;/path/to/repo.git/\r
368 </simpara>\r
369 </listitem>\r
370 <listitem>\r
371 <simpara>\r
372 &#91;user@&#93;host.xz:/~&#91;user&#93;/path/to/repo.git/\r
373 </simpara>\r
374 </listitem>\r
375 </itemizedlist>\r
376 <simpara>For local repositories, also supported by git natively, the following\r
377 syntaxes may be used:</simpara>\r
378 <itemizedlist>\r
379 <listitem>\r
380 <simpara>\r
381 /path/to/repo.git/\r
382 </simpara>\r
383 </listitem>\r
384 <listitem>\r
385 <simpara>\r
386 <ulink url="file:///path/to/repo.git/">file:///path/to/repo.git/</ulink>\r
387 </simpara>\r
388 </listitem>\r
389 </itemizedlist>\r
390 <simpara>These two syntaxes are mostly equivalent, except when cloning, when\r
391 the former implies --local option. See <xref linkend="git-clone(1)" /> for\r
392 details.</simpara>\r
393 <simpara>When git doesn't know how to handle a certain transport protocol, it\r
394 attempts to use the <emphasis>remote-&lt;transport&gt;</emphasis> remote helper, if one\r
395 exists. To explicitly request a remote helper, the following syntax\r
396 may be used:</simpara>\r
397 <itemizedlist>\r
398 <listitem>\r
399 <simpara>\r
400 &lt;transport&gt;::&lt;address&gt;\r
401 </simpara>\r
402 </listitem>\r
403 </itemizedlist>\r
404 <simpara>where &lt;address&gt; may be a path, a server and path, or an arbitrary\r
405 URL-like string recognized by the specific remote helper being\r
406 invoked. See <xref linkend="git-remote-helpers(1)" /> for details.</simpara>\r
407 <simpara>If there are a large number of similarly-named remote repositories and\r
408 you want to use a different format for them (such that the URLs you\r
409 use will be rewritten into URLs that work), you can create a\r
410 configuration section of the form:</simpara>\r
411 <screen>        [url "&lt;actual url base&gt;"]\r
412                 insteadOf = &lt;other url base&gt;</screen>\r
413 <simpara>For example, with this:</simpara>\r
414 <screen>        [url "git://git.host.xz/"]\r
415                 insteadOf = host.xz:/path/to/\r
416                 insteadOf = work:</screen>\r
417 <simpara>a URL like "work:repo.git" or like "host.xz:/path/to/repo.git" will be\r
418 rewritten in any context that takes a URL to be "git://git.host.xz/repo.git".</simpara>\r
419 <simpara>If you want to rewrite URLs for push only, you can create a\r
420 configuration section of the form:</simpara>\r
421 <screen>        [url "&lt;actual url base&gt;"]\r
422                 pushInsteadOf = &lt;other url base&gt;</screen>\r
423 <simpara>For example, with this:</simpara>\r
424 <screen>        [url "ssh://example.org/"]\r
425                 pushInsteadOf = git://example.org/</screen>\r
426 <simpara>a URL like "git://example.org/path/to/repo.git" will be rewritten to\r
427 "ssh://example.org/path/to/repo.git" for pushes, but pulls will still\r
428 use the original URL.</simpara>\r
429 </simplesect>\r
430 <simplesect id="_remotes_anchor_id_remotes_xreflabel_remotes">\r
431 <title>REMOTES<anchor id="REMOTES" xreflabel="[REMOTES]"/></title>\r
432 <simpara>The name of one of the following can be used instead\r
433 of a URL as <emphasis>&lt;repository&gt;</emphasis> argument:</simpara>\r
434 <itemizedlist>\r
435 <listitem>\r
436 <simpara>\r
437 a remote in the git configuration file: <emphasis>$GIT_DIR/config</emphasis>,\r
438 </simpara>\r
439 </listitem>\r
440 <listitem>\r
441 <simpara>\r
442 a file in the <emphasis>$GIT_DIR/remotes</emphasis> directory, or\r
443 </simpara>\r
444 </listitem>\r
445 <listitem>\r
446 <simpara>\r
447 a file in the <emphasis>$GIT_DIR/branches</emphasis> directory.\r
448 </simpara>\r
449 </listitem>\r
450 </itemizedlist>\r
451 <simpara>All of these also allow you to omit the refspec from the command line\r
452 because they each contain a refspec which git will use by default.</simpara>\r
453 <section id="_named_remote_in_configuration_file">\r
454 <title>Named remote in configuration file</title>\r
455 <simpara>You can choose to provide the name of a remote which you had previously\r
456 configured using <xref linkend="git-remote(1)" />, <xref linkend="git-config(1)" />\r
457 or even by a manual edit to the <emphasis>$GIT_DIR/config</emphasis> file.  The URL of\r
458 this remote will be used to access the repository.  The refspec\r
459 of this remote will be used by default when you do\r
460 not provide a refspec on the command line.  The entry in the\r
461 config file would appear like this:</simpara>\r
462 <screen>        [remote "&lt;name&gt;"]\r
463                 url = &lt;url&gt;\r
464                 pushurl = &lt;pushurl&gt;\r
465                 push = &lt;refspec&gt;\r
466                 fetch = &lt;refspec&gt;</screen>\r
467 <simpara>The <emphasis>&lt;pushurl&gt;</emphasis> is used for pushes only. It is optional and defaults\r
468 to <emphasis>&lt;url&gt;</emphasis>.</simpara>\r
469 </section>\r
470 <section id="_named_file_in_emphasis_git_dir_remotes_emphasis">\r
471 <title>Named file in <emphasis>$GIT_DIR/remotes</emphasis></title>\r
472 <simpara>You can choose to provide the name of a\r
473 file in <emphasis>$GIT_DIR/remotes</emphasis>.  The URL\r
474 in this file will be used to access the repository.  The refspec\r
475 in this file will be used as default when you do not\r
476 provide a refspec on the command line.  This file should have the\r
477 following format:</simpara>\r
478 <screen>        URL: one of the above URL format\r
479         Push: &lt;refspec&gt;\r
480         Pull: &lt;refspec&gt;</screen>\r
481 <simpara><emphasis>Push:</emphasis> lines are used by <emphasis>git push</emphasis> and\r
482 <emphasis>Pull:</emphasis> lines are used by <emphasis>git pull</emphasis> and <emphasis>git fetch</emphasis>.\r
483 Multiple <emphasis>Push:</emphasis> and <emphasis>Pull:</emphasis> lines may\r
484 be specified for additional branch mappings.</simpara>\r
485 </section>\r
486 <section id="_named_file_in_emphasis_git_dir_branches_emphasis">\r
487 <title>Named file in <emphasis>$GIT_DIR/branches</emphasis></title>\r
488 <simpara>You can choose to provide the name of a\r
489 file in <emphasis>$GIT_DIR/branches</emphasis>.\r
490 The URL in this file will be used to access the repository.\r
491 This file should have the following format:</simpara>\r
492 <screen>        &lt;url&gt;#&lt;head&gt;</screen>\r
493 <simpara><emphasis>&lt;url&gt;</emphasis> is required; <emphasis>#&lt;head&gt;</emphasis> is optional.</simpara>\r
494 <simpara>Depending on the operation, git will use one of the following\r
495 refspecs, if you don't provide one on the command line.\r
496 <emphasis>&lt;branch&gt;</emphasis> is the name of this file in <emphasis>$GIT_DIR/branches</emphasis> and\r
497 <emphasis>&lt;head&gt;</emphasis> defaults to <emphasis>master</emphasis>.</simpara>\r
498 <simpara>git fetch uses:</simpara>\r
499 <screen>        refs/heads/&lt;head&gt;:refs/heads/&lt;branch&gt;</screen>\r
500 <simpara>git push uses:</simpara>\r
501 <screen>        HEAD:refs/heads/&lt;head&gt;</screen>\r
502 </section>\r
503 </simplesect>\r
504 <simplesect id="_output">\r
505 <title>OUTPUT</title>\r
506 <simpara>The output of "git push" depends on the transport method used; this\r
507 section describes the output when pushing over the git protocol (either\r
508 locally or via ssh).</simpara>\r
509 <simpara>The status of the push is output in tabular form, with each line\r
510 representing the status of a single ref. Each line is of the form:</simpara>\r
511 <screen> &lt;flag&gt; &lt;summary&gt; &lt;from&gt; -&gt; &lt;to&gt; (&lt;reason&gt;)</screen>\r
512 <simpara>If --porcelain is used, then each line of the output is of the form:</simpara>\r
513 <screen> &lt;flag&gt; \t &lt;from&gt;:&lt;to&gt; \t &lt;summary&gt; (&lt;reason&gt;)</screen>\r
514 <simpara>The status of up-to-date refs is shown only if --porcelain or --verbose\r
515 option is used.</simpara>\r
516 <variablelist>\r
517 <varlistentry>\r
518 <term>\r
519 flag\r
520 </term>\r
521 <listitem>\r
522 <simpara>\r
523         A single character indicating the status of the ref:\r
524 </simpara>\r
525 <variablelist>\r
526 <varlistentry>\r
527 <term>\r
528 (space)\r
529 </term>\r
530 <listitem>\r
531 <simpara>\r
532 for a successfully pushed fast-forward;\r
533 </simpara>\r
534 </listitem>\r
535 </varlistentry>\r
536 <varlistentry>\r
537 <term>\r
538 <emphasis>+</emphasis>\r
539 </term>\r
540 <listitem>\r
541 <simpara>\r
542 for a successful forced update;\r
543 </simpara>\r
544 </listitem>\r
545 </varlistentry>\r
546 <varlistentry>\r
547 <term>\r
548 <emphasis>-</emphasis>\r
549 </term>\r
550 <listitem>\r
551 <simpara>\r
552 for a successfully deleted ref;\r
553 </simpara>\r
554 </listitem>\r
555 </varlistentry>\r
556 <varlistentry>\r
557 <term>\r
558 <emphasis>*</emphasis>\r
559 </term>\r
560 <listitem>\r
561 <simpara>\r
562 for a successfully pushed new ref;\r
563 </simpara>\r
564 </listitem>\r
565 </varlistentry>\r
566 <varlistentry>\r
567 <term>\r
568 <emphasis>!</emphasis>\r
569 </term>\r
570 <listitem>\r
571 <simpara>\r
572 for a ref that was rejected or failed to push; and\r
573 </simpara>\r
574 </listitem>\r
575 </varlistentry>\r
576 <varlistentry>\r
577 <term>\r
578 <emphasis>=</emphasis>\r
579 </term>\r
580 <listitem>\r
581 <simpara>\r
582 for a ref that was up to date and did not need pushing.\r
583 </simpara>\r
584 </listitem>\r
585 </varlistentry>\r
586 </variablelist>\r
587 </listitem>\r
588 </varlistentry>\r
589 <varlistentry>\r
590 <term>\r
591 summary\r
592 </term>\r
593 <listitem>\r
594 <simpara>\r
595         For a successfully pushed ref, the summary shows the old and new\r
596         values of the ref in a form suitable for using as an argument to\r
597         <emphasis>git log</emphasis> (this is <emphasis>&lt;old&gt;..&lt;new&gt;</emphasis> in most cases, and\r
598         <emphasis>&lt;old&gt;...&lt;new&gt;</emphasis> for forced non-fast-forward updates).\r
599 </simpara>\r
600 <simpara>For a failed update, more details are given:</simpara>\r
601 <variablelist>\r
602 <varlistentry>\r
603 <term>\r
604 rejected\r
605 </term>\r
606 <listitem>\r
607 <simpara>\r
608         Git did not try to send the ref at all, typically because it\r
609         is not a fast-forward and you did not force the update.\r
610 </simpara>\r
611 </listitem>\r
612 </varlistentry>\r
613 <varlistentry>\r
614 <term>\r
615 remote rejected\r
616 </term>\r
617 <listitem>\r
618 <simpara>\r
619         The remote end refused the update.  Usually caused by a hook\r
620         on the remote side, or because the remote repository has one\r
621         of the following safety options in effect:\r
622         <emphasis>receive.denyCurrentBranch</emphasis> (for pushes to the checked out\r
623         branch), <emphasis>receive.denyNonFastForwards</emphasis> (for forced\r
624         non-fast-forward updates), <emphasis>receive.denyDeletes</emphasis> or\r
625         <emphasis>receive.denyDeleteCurrent</emphasis>.  See <xref linkend="git-config(1)" />.\r
626 </simpara>\r
627 </listitem>\r
628 </varlistentry>\r
629 <varlistentry>\r
630 <term>\r
631 remote failure\r
632 </term>\r
633 <listitem>\r
634 <simpara>\r
635         The remote end did not report the successful update of the ref,\r
636         perhaps because of a temporary error on the remote side, a\r
637         break in the network connection, or other transient error.\r
638 </simpara>\r
639 </listitem>\r
640 </varlistentry>\r
641 </variablelist>\r
642 </listitem>\r
643 </varlistentry>\r
644 <varlistentry>\r
645 <term>\r
646 from\r
647 </term>\r
648 <listitem>\r
649 <simpara>\r
650         The name of the local ref being pushed, minus its\r
651         <emphasis>refs/&lt;type&gt;/</emphasis> prefix. In the case of deletion, the\r
652         name of the local ref is omitted.\r
653 </simpara>\r
654 </listitem>\r
655 </varlistentry>\r
656 <varlistentry>\r
657 <term>\r
658 to\r
659 </term>\r
660 <listitem>\r
661 <simpara>\r
662         The name of the remote ref being updated, minus its\r
663         <emphasis>refs/&lt;type&gt;/</emphasis> prefix.\r
664 </simpara>\r
665 </listitem>\r
666 </varlistentry>\r
667 <varlistentry>\r
668 <term>\r
669 reason\r
670 </term>\r
671 <listitem>\r
672 <simpara>\r
673         A human-readable explanation. In the case of successfully pushed\r
674         refs, no explanation is needed. For a failed ref, the reason for\r
675         failure is described.\r
676 </simpara>\r
677 </listitem>\r
678 </varlistentry>\r
679 </variablelist>\r
680 </simplesect>\r
681 <simplesect id="_note_about_fast_forwards">\r
682 <title>Note about fast-forwards</title>\r
683 <simpara>When an update changes a branch (or more in general, a ref) that used to\r
684 point at commit A to point at another commit B, it is called a\r
685 fast-forward update if and only if B is a descendant of A.</simpara>\r
686 <simpara>In a fast-forward update from A to B, the set of commits that the original\r
687 commit A built on top of is a subset of the commits the new commit B\r
688 builds on top of.  Hence, it does not lose any history.</simpara>\r
689 <simpara>In contrast, a non-fast-forward update will lose history.  For example,\r
690 suppose you and somebody else started at the same commit X, and you built\r
691 a history leading to commit B while the other person built a history\r
692 leading to commit A.  The history looks like this:</simpara>\r
693 <screen>      B\r
694      /\r
695  ---X---A</screen>\r
696 <simpara>Further suppose that the other person already pushed changes leading to A\r
697 back to the original repository you two obtained the original commit X.</simpara>\r
698 <simpara>The push done by the other person updated the branch that used to point at\r
699 commit X to point at commit A.  It is a fast-forward.</simpara>\r
700 <simpara>But if you try to push, you will attempt to update the branch (that\r
701 now points at A) with commit B.  This does <emphasis>not</emphasis> fast-forward.  If you did\r
702 so, the changes introduced by commit A will be lost, because everybody\r
703 will now start building on top of B.</simpara>\r
704 <simpara>The command by default does not allow an update that is not a fast-forward\r
705 to prevent such loss of history.</simpara>\r
706 <simpara>If you do not want to lose your work (history from X to B) nor the work by\r
707 the other person (history from X to A), you would need to first fetch the\r
708 history from the repository, create a history that contains changes done\r
709 by both parties, and push the result back.</simpara>\r
710 <simpara>You can perform "git pull", resolve potential conflicts, and "git push"\r
711 the result.  A "git pull" will create a merge commit C between commits A\r
712 and B.</simpara>\r
713 <screen>      B---C\r
714      /   /\r
715  ---X---A</screen>\r
716 <simpara>Updating A with the resulting merge commit will fast-forward and your\r
717 push will be accepted.</simpara>\r
718 <simpara>Alternatively, you can rebase your change between X and B on top of A,\r
719 with "git pull --rebase", and push the result back.  The rebase will\r
720 create a new commit D that builds the change between X and B on top of\r
721 A.</simpara>\r
722 <screen>      B   D\r
723      /   /\r
724  ---X---A</screen>\r
725 <simpara>Again, updating A with this commit will fast-forward and your push will be\r
726 accepted.</simpara>\r
727 <simpara>There is another common situation where you may encounter non-fast-forward\r
728 rejection when you try to push, and it is possible even when you are\r
729 pushing into a repository nobody else pushes into. After you push commit\r
730 A yourself (in the first picture in this section), replace it with "git\r
731 commit --amend" to produce commit B, and you try to push it out, because\r
732 forgot that you have pushed A out already. In such a case, and only if\r
733 you are certain that nobody in the meantime fetched your earlier commit A\r
734 (and started building on top of it), you can run "git push --force" to\r
735 overwrite it. In other words, "git push --force" is a method reserved for\r
736 a case where you do mean to lose history.</simpara>\r
737 </simplesect>\r
738 <simplesect id="_examples">\r
739 <title>Examples</title>\r
740 <variablelist>\r
741 <varlistentry>\r
742 <term>\r
743 <emphasis>git push</emphasis>\r
744 </term>\r
745 <listitem>\r
746 <simpara>\r
747         Works like <emphasis>git push &lt;remote&gt;</emphasis>, where &lt;remote&gt; is the\r
748         current branch's remote (or <emphasis>origin</emphasis>, if no remote is\r
749         configured for the current branch).\r
750 </simpara>\r
751 </listitem>\r
752 </varlistentry>\r
753 <varlistentry>\r
754 <term>\r
755 <emphasis>git push origin</emphasis>\r
756 </term>\r
757 <listitem>\r
758 <simpara>\r
759         Without additional configuration, works like\r
760         <emphasis>git push origin :</emphasis>.\r
761 </simpara>\r
762 <simpara>The default behavior of this command when no &lt;refspec&gt; is given can be\r
763 configured by setting the <emphasis>push</emphasis> option of the remote.</simpara>\r
764 <simpara>For example, to default to pushing only the current branch to <emphasis>origin</emphasis>\r
765 use <emphasis>git config remote.origin.push HEAD</emphasis>.  Any valid &lt;refspec&gt; (like\r
766 the ones in the examples below) can be configured as the default for\r
767 <emphasis>git push origin</emphasis>.</simpara>\r
768 </listitem>\r
769 </varlistentry>\r
770 <varlistentry>\r
771 <term>\r
772 <emphasis>git push origin :</emphasis>\r
773 </term>\r
774 <listitem>\r
775 <simpara>\r
776         Push "matching" branches to <emphasis>origin</emphasis>. See\r
777         &lt;refspec&gt; in the <link linkend="OPTIONS">OPTIONS</link> section above for a\r
778         description of "matching" branches.\r
779 </simpara>\r
780 </listitem>\r
781 </varlistentry>\r
782 <varlistentry>\r
783 <term>\r
784 <emphasis>git push origin master</emphasis>\r
785 </term>\r
786 <listitem>\r
787 <simpara>\r
788         Find a ref that matches <emphasis>master</emphasis> in the source repository\r
789         (most likely, it would find <emphasis>refs/heads/master</emphasis>), and update\r
790         the same ref (e.g. <emphasis>refs/heads/master</emphasis>) in <emphasis>origin</emphasis> repository\r
791         with it.  If <emphasis>master</emphasis> did not exist remotely, it would be\r
792         created.\r
793 </simpara>\r
794 </listitem>\r
795 </varlistentry>\r
796 <varlistentry>\r
797 <term>\r
798 <emphasis>git push origin HEAD</emphasis>\r
799 </term>\r
800 <listitem>\r
801 <simpara>\r
802         A handy way to push the current branch to the same name on the\r
803         remote.\r
804 </simpara>\r
805 </listitem>\r
806 </varlistentry>\r
807 <varlistentry>\r
808 <term>\r
809 <emphasis>git push origin master:satellite/master dev:satellite/dev</emphasis>\r
810 </term>\r
811 <listitem>\r
812 <simpara>\r
813         Use the source ref that matches <emphasis>master</emphasis> (e.g. <emphasis>refs/heads/master</emphasis>)\r
814         to update the ref that matches <emphasis>satellite/master</emphasis> (most probably\r
815         <emphasis>refs/remotes/satellite/master</emphasis>) in the <emphasis>origin</emphasis> repository, then\r
816         do the same for <emphasis>dev</emphasis> and <emphasis>satellite/dev</emphasis>.\r
817 </simpara>\r
818 </listitem>\r
819 </varlistentry>\r
820 <varlistentry>\r
821 <term>\r
822 <emphasis>git push origin HEAD:master</emphasis>\r
823 </term>\r
824 <listitem>\r
825 <simpara>\r
826         Push the current branch to the remote ref matching <emphasis>master</emphasis> in the\r
827         <emphasis>origin</emphasis> repository. This form is convenient to push the current\r
828         branch without thinking about its local name.\r
829 </simpara>\r
830 </listitem>\r
831 </varlistentry>\r
832 <varlistentry>\r
833 <term>\r
834 <emphasis>git push origin master:refs/heads/experimental</emphasis>\r
835 </term>\r
836 <listitem>\r
837 <simpara>\r
838         Create the branch <emphasis>experimental</emphasis> in the <emphasis>origin</emphasis> repository\r
839         by copying the current <emphasis>master</emphasis> branch.  This form is only\r
840         needed to create a new branch or tag in the remote repository when\r
841         the local name and the remote name are different; otherwise,\r
842         the ref name on its own will work.\r
843 </simpara>\r
844 </listitem>\r
845 </varlistentry>\r
846 <varlistentry>\r
847 <term>\r
848 <emphasis>git push origin :experimental</emphasis>\r
849 </term>\r
850 <listitem>\r
851 <simpara>\r
852         Find a ref that matches <emphasis>experimental</emphasis> in the <emphasis>origin</emphasis> repository\r
853         (e.g. <emphasis>refs/heads/experimental</emphasis>), and delete it.\r
854 </simpara>\r
855 </listitem>\r
856 </varlistentry>\r
857 <varlistentry>\r
858 <term>\r
859 <emphasis>git push origin +dev:master</emphasis>\r
860 </term>\r
861 <listitem>\r
862 <simpara>\r
863         Update the origin repository's master branch with the dev branch,\r
864         allowing non-fast-forward updates.  <emphasis role="strong">This can leave unreferenced\r
865         commits dangling in the origin repository.</emphasis>  Consider the\r
866         following situation, where a fast-forward is not possible:\r
867 </simpara>\r
868 <screen>            o---o---o---A---B  origin/master\r
869                      \\r
870                       X---Y---Z  dev</screen>\r
871 <simpara>The above command would change the origin repository to</simpara>\r
872 <screen>                      A---B  (unnamed branch)\r
873                      /\r
874             o---o---o---X---Y---Z  master</screen>\r
875 <simpara>Commits A and B would no longer belong to a branch with a symbolic name,\r
876 and so would be unreachable.  As such, these commits would be removed by\r
877 a <emphasis>git gc</emphasis> command on the origin repository.</simpara>\r
878 </listitem>\r
879 </varlistentry>\r
880 </variablelist>\r
881 </simplesect>\r
882 <simplesect id="_git">\r
883 <title>GIT</title>\r
884 <simpara>Part of the <xref linkend="git(1)" /> suite</simpara>\r
885 </simplesect>\r
886 </article>\r