1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en">
5 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8" />
6 <meta name=
"generator" content=
"AsciiDoc 8.5.2" />
7 <title>git-push(
1)
</title>
8 <style type=
"text/css">
10 p
, li
, dt
, dd
, div
, pre
, h1
, h2
, h3
, h4
, h5
, h6
{
12 border: 1px solid red;
17 margin: 1em 5% 1em 5%;
22 text-decoration: underline
;
42 h1
, h2
, h3
, h4
, h5
, h6
{
44 font-family: sans-serif
;
51 border-bottom: 2px solid silver
;
69 border: 1px solid silver
;
88 font-family: sans-serif
;
94 span#revnumber
, span#revdate
, span#revremark
{
95 font-family: sans-serif
;
99 font-family: sans-serif
;
101 border-top: 2px solid silver
;
107 padding-bottom: 0.5em;
111 padding-bottom: 0.5em;
116 margin-bottom: 1.5em;
118 div
.tableblock
, div
.imageblock
, div
.exampleblock
, div
.verseblock
,
119 div
.quoteblock
, div
.literalblock
, div
.listingblock
, div
.sidebarblock
,
120 div
.admonitionblock
{
122 margin-bottom: 1.5em;
124 div
.admonitionblock
{
126 margin-bottom: 2.0em;
131 div
.content
{ /* Block element content. */
135 /* Block element titles. */
136 div
.title
, caption
.title
{
138 font-family: sans-serif
;
142 margin-bottom: 0.5em;
148 td div
.title:first-child
{
151 div
.content div
.title:first-child
{
154 div
.content
+ div
.title
{
158 div
.sidebarblock
> div
.content
{
160 border: 1px solid silver
;
164 div
.listingblock
> div
.content
{
165 border: 1px solid silver
;
170 div
.quoteblock
, div
.verseblock
{
174 border-left: 5px solid
#dddddd;
178 div
.quoteblock
> div
.attribution
{
183 div
.verseblock
> div
.content
{
186 div
.verseblock
> div
.attribution
{
190 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
191 div
.verseblock
+ div
.attribution
{
195 div
.admonitionblock
.icon
{
199 text-decoration: underline
;
201 padding-right: 0.5em;
203 div
.admonitionblock td
.content
{
205 border-left: 3px solid
#dddddd;
208 div
.exampleblock
> div
.content
{
209 border-left: 3px solid
#dddddd;
213 div
.imageblock div
.content
{ padding-left: 0; }
214 span
.image img
{ border-style: none
; }
215 a
.image:visited
{ color: white
; }
219 margin-bottom: 0.8em;
232 list-style-position: outside
;
235 list-style-type: decimal
;
238 list-style-type: lower-alpha
;
241 list-style-type: upper-alpha
;
244 list-style-type: lower-roman
;
247 list-style-type: upper-roman
;
250 div
.compact ul
, div
.compact ol
,
251 div
.compact p
, div
.compact p
,
252 div
.compact div
, div
.compact div
{
254 margin-bottom: 0.1em;
257 div
.tableblock
> table
{
258 border: 3px solid
#527bbd;
260 thead
, p
.table
.header
{
261 font-family: sans-serif
;
273 /* Because the table frame attribute is overriden by CSS in most browsers. */
274 div
.tableblock
> table
[frame
="void"] {
277 div
.tableblock
> table
[frame
="hsides"] {
278 border-left-style: none
;
279 border-right-style: none
;
281 div
.tableblock
> table
[frame
="vsides"] {
282 border-top-style: none
;
283 border-bottom-style: none
;
289 margin-bottom: 0.8em;
292 padding-bottom: 15px;
294 dt
.hdlist1
.strong
, td
.hdlist1
.strong
{
300 padding-right: 0.8em;
306 div
.hdlist
.compact tr
{
315 .footnote, .footnoteref {
319 span
.footnote
, span
.footnoteref
{
320 vertical-align: super
;
324 margin: 20px 0 20px 0;
328 #footnotes div
.footnote
{
334 border-top: 1px solid silver
;
344 div#footer-badges
{ display: none
; }
348 margin-bottom: 2.5em;
353 font-family: sans-serif
;
357 margin-bottom: 0.1em;
360 div
.toclevel1
, div
.toclevel2
, div
.toclevel3
, div
.toclevel4
{
376 /* Overrides for manpage documents */
379 padding-bottom: 0.5em;
380 border-top: 2px solid silver
;
381 border-bottom: 2px solid silver
;
391 div#toc
{ display: none
; }
394 /* Workarounds for IE6's broken and incomplete CSS2. */
396 div
.sidebar-content
{
398 border: 1px solid silver
;
401 div
.sidebar-title
, div
.image-title
{
403 font-family: sans-serif
;
406 margin-bottom: 0.5em;
409 div
.listingblock div
.content
{
410 border: 1px solid silver
;
415 div
.quoteblock-attribution
{
420 div
.verseblock-content
{
423 div
.verseblock-attribution
{
428 div
.exampleblock-content
{
429 border-left: 3px solid
#dddddd;
433 /* IE6 sets dynamically generated links as visited. */
434 div#toc
a:visited
{ color: blue
; }
436 <script type=
"text/javascript">
438 window
.onload = function(){asciidoc
.footnotes();}
439 var asciidoc
= { // Namespace.
441 /////////////////////////////////////////////////////////////////////
442 // Table Of Contents generator
443 /////////////////////////////////////////////////////////////////////
445 /* Author: Mihai Bazon, September 2002
446 * http://students.infoiasi.ro/~mishoo
448 * Table Of Content generator
451 * Feel free to use this script under the terms of the GNU General Public
452 * License, as long as you do not remove or alter this notice.
455 /* modified by Troy D. Hanson, September 2006. License: GPL */
456 /* modified by Stuart Rackham, 2006, 2009. License: GPL */
459 toc: function (toclevels
) {
461 function getText(el
) {
463 for (var i
= el
.firstChild
; i
!= null; i
= i
.nextSibling
) {
464 if (i
.nodeType
== 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
466 else if (i
.firstChild
!= null)
472 function TocEntry(el
, text
, toclevel
) {
475 this.toclevel
= toclevel
;
478 function tocEntries(el
, toclevels
) {
479 var result
= new Array
;
480 var re
= new RegExp('[hH]([2-'+(toclevels
+1)+'])');
481 // Function that scans the DOM tree for header elements (the DOM2
482 // nodeIterator API would be a better technique but not supported by all
484 var iterate = function (el
) {
485 for (var i
= el
.firstChild
; i
!= null; i
= i
.nextSibling
) {
486 if (i
.nodeType
== 1 /* Node.ELEMENT_NODE */) {
487 var mo
= re
.exec(i
.tagName
);
488 if (mo
&& (i
.getAttribute("class") || i
.getAttribute("className")) != "float") {
489 result
[result
.length
] = new TocEntry(i
, getText(i
), mo
[1]-1);
499 var toc
= document
.getElementById("toc");
500 var entries
= tocEntries(document
.getElementById("content"), toclevels
);
501 for (var i
= 0; i
< entries
.length
; ++i
) {
502 var entry
= entries
[i
];
503 if (entry
.element
.id
== "")
504 entry
.element
.id
= "_toc_" + i
;
505 var a
= document
.createElement("a");
506 a
.href
= "#" + entry
.element
.id
;
507 a
.appendChild(document
.createTextNode(entry
.text
));
508 var div
= document
.createElement("div");
510 div
.className
= "toclevel" + entry
.toclevel
;
511 toc
.appendChild(div
);
513 if (entries
.length
== 0)
514 toc
.parentNode
.removeChild(toc
);
518 /////////////////////////////////////////////////////////////////////
519 // Footnotes generator
520 /////////////////////////////////////////////////////////////////////
522 /* Based on footnote generation code from:
523 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
526 footnotes: function () {
527 var cont
= document
.getElementById("content");
528 var noteholder
= document
.getElementById("footnotes");
529 var spans
= cont
.getElementsByTagName("span");
532 for (i
=0; i
<spans
.length
; i
++) {
533 if (spans
[i
].className
== "footnote") {
535 // Use [\s\S] in place of . so multi-line matches work.
536 // Because JavaScript has no s (dotall) regex flag.
537 note
= spans
[i
].innerHTML
.match(/\s*\[([\s\S]*)]\s*/)[1];
538 noteholder
.innerHTML
+=
539 "<div class='footnote' id='_footnote_" + n
+ "'>" +
540 "<a href='#_footnoteref_" + n
+ "' title='Return to text'>" +
541 n
+ "</a>. " + note
+ "</div>";
543 "[<a id='_footnoteref_" + n
+ "' href='#_footnote_" + n
+
544 "' title='View footnote' class='footnote'>" + n
+ "</a>]";
545 var id
=spans
[i
].getAttribute("id");
546 if (id
!= null) refs
["#"+id
] = n
;
550 noteholder
.parentNode
.removeChild(noteholder
);
552 // Process footnoterefs.
553 for (i
=0; i
<spans
.length
; i
++) {
554 if (spans
[i
].className
== "footnoteref") {
555 var href
= spans
[i
].getElementsByTagName("a")[0].getAttribute("href");
556 href
= href
.match(/#.*/)[0]; // Because IE return full URL.
559 "[<a href='#_footnote_" + n
+
560 "' title='View footnote' class='footnote'>" + n
+ "</a>]";
573 git-push(
1) Manual Page
576 <div class=
"sectionbody">
578 Update remote refs along with associated objects
583 <h2 id=
"_synopsis">SYNOPSIS
</h2>
584 <div class=
"sectionbody">
585 <div class=
"verseblock">
586 <div class=
"verseblock-content"><em>git push
</em> [--all | --mirror | --tags] [-n | --dry-run] [--receive-pack=
<git-receive-pack
>]
587 [--repo=
<repository
>] [-f | --force] [-v | --verbose] [-u | --set-upstream]
588 [
<repository
> [
<refspec
>…]]
</div>
589 <div class=
"verseblock-attribution">
592 <h2 id=
"_description">DESCRIPTION
</h2>
593 <div class=
"sectionbody">
594 <div class=
"paragraph"><p>Updates remote refs using local refs, while sending objects
595 necessary to complete the given refs.
</p></div>
596 <div class=
"paragraph"><p>You can make interesting things happen to a repository
597 every time you push into it, by setting up
<em>hooks
</em> there. See
598 documentation for
<a href=
"git-receive-pack.html">git-receive-pack(
1)
</a>.
</p></div>
600 <h2 id=
"_options_a_id_options_a">OPTIONS
<a id=
"OPTIONS"></a></h2>
601 <div class=
"sectionbody">
602 <div class=
"dlist"><dl>
608 The
"remote" repository that is destination of a push
609 operation. This parameter can be either a URL
610 (see the section
<a href=
"#URLS">GIT URLS
</a> below) or the name
611 of a remote (see the section
<a href=
"#REMOTES">REMOTES
</a> below).
615 <refspec
>…
619 The format of a
<refspec
> parameter is an optional plus
620 <tt>+</tt>, followed by the source ref
<src
>, followed
621 by a colon
<tt>:
</tt>, followed by the destination ref
<dst
>.
622 It is used to specify with what
<src
> object the
<dst
> ref
623 in the remote repository is to be updated.
625 <div class=
"paragraph"><p>The
<src
> is often the name of the branch you would want to push, but
626 it can be any arbitrary
"SHA-1 expression", such as
<tt>master~
4</tt> or
627 <tt>HEAD
</tt> (see
<a href=
"gitrevisions.html">gitrevisions(
7)
</a>).
</p></div>
628 <div class=
"paragraph"><p>The
<dst
> tells which ref on the remote side is updated with this
629 push. Arbitrary expressions cannot be used here, an actual ref must
630 be named. If
<tt>:
</tt><dst
> is omitted, the same ref as
<src
> will be
632 <div class=
"paragraph"><p>The object referenced by
<src
> is used to update the
<dst
> reference
633 on the remote side, but by default this is only allowed if the
634 update can fast-forward
<dst
>. By having the optional leading
<tt>+</tt>,
635 you can tell git to update the
<dst
> ref even when the update is not a
636 fast-forward. This does
<strong>not
</strong> attempt to merge
<src
> into
<dst
>. See
637 EXAMPLES below for details.
</p></div>
638 <div class=
"paragraph"><p><tt>tag
<tag
></tt> means the same as
<tt>refs/tags/
<tag
>:refs/tags/
<tag
></tt>.
</p></div>
639 <div class=
"paragraph"><p>Pushing an empty
<src
> allows you to delete the
<dst
> ref from
640 the remote repository.
</p></div>
641 <div class=
"paragraph"><p>The special refspec
<tt>:
</tt> (or
<tt>+:
</tt> to allow non-fast-forward updates)
642 directs git to push
"matching" branches: for every branch that exists on
643 the local side, the remote side is updated if a branch of the same name
644 already exists on the remote side. This is the default operation mode
645 if no explicit refspec is found (that is neither on the command line
646 nor in any Push line of the corresponding remotes file---see below).
</p></div>
653 Instead of naming each ref to push, specifies that all
654 refs under
<tt>refs/heads/
</tt> be pushed.
662 Instead of naming each ref to push, specifies that all
663 refs under
<tt>refs/
</tt> (which includes but is not
664 limited to
<tt>refs/heads/
</tt>,
<tt>refs/remotes/
</tt>, and
<tt>refs/tags/
</tt>)
665 be mirrored to the remote repository. Newly created local
666 refs will be pushed to the remote end, locally updated refs
667 will be force updated on the remote end, and deleted refs
668 will be removed from the remote end. This is the default
669 if the configuration option
<tt>remote.
<remote
>.mirror
</tt> is
681 Do everything except actually send the updates.
689 Produce machine-readable output. The output status line for each ref
690 will be tab-separated and sent to stdout instead of stderr. The full
691 symbolic names of the refs will be given.
699 All listed refs are deleted from the remote repository. This is
700 the same as prefixing all refs with a colon.
708 All refs under
<tt>refs/tags
</tt> are pushed, in
709 addition to refspecs explicitly listed on the command
714 --receive-pack=
<git-receive-pack
>
717 --exec=
<git-receive-pack
>
721 Path to the
<em>git-receive-pack
</em> program on the remote
722 end. Sometimes useful when pushing to a remote
723 repository over ssh, and you do not have the program in
724 a directory on the default $PATH.
735 Usually, the command refuses to update a remote ref that is
736 not an ancestor of the local ref used to overwrite it.
737 This flag disables the check. This can cause the
738 remote repository to lose commits; use it with care.
742 --repo=
<repository
>
746 This option is only relevant if no
<repository
> argument is
747 passed in the invocation. In this case,
<em>git push
</em> derives the
748 remote name from the current branch: If it tracks a remote
749 branch, then that remote repository is pushed to. Otherwise,
750 the name
"origin" is used. For this latter case, this option
751 can be used to override the name
"origin". In other words,
752 the difference between these two commands
754 <div class=
"listingblock">
755 <div class=
"content">
756 <pre><tt>git push public #
1
757 git push --repo=public #
2</tt></pre>
759 <div class=
"paragraph"><p>is that #
1 always pushes to
"public" whereas #
2 pushes to
"public"
760 only if the current branch does not track a remote branch. This is
761 useful if you write an alias or script around
<em>git push
</em>.
</p></div>
771 For every branch that is up to date or successfully pushed, add
772 upstream (tracking) reference, used by argument-less
773 <a href=
"git-pull.html">git-pull(
1)
</a> and other commands. For more information,
774 see
<em>branch.
<name
>.merge
</em> in
<a href=
"git-config.html">git-config(
1)
</a>.
785 These options are passed to
<a href=
"git-send-pack.html">git-send-pack(
1)
</a>. A thin transfer
786 significantly reduces the amount of sent data when the sender and
787 receiver share many of the same objects in common. The default is
799 Suppress all output, including the listing of updated refs,
800 unless an error occurs. Progress is not reported to the standard
820 Progress status is reported on the standard error stream
821 by default when it is attached to a terminal, unless -q
822 is specified. This flag forces progress status even if the
823 standard error stream is not directed to a terminal.
827 --recurse-submodules=check
831 Check whether all submodule commits used by the revisions to be
832 pushed are available on a remote tracking branch. Otherwise the
833 push will be aborted and the command will exit with non-zero status.
838 <h2 id=
"_git_urls_a_id_urls_a">GIT URLS
<a id=
"URLS"></a></h2>
839 <div class=
"sectionbody">
840 <div class=
"paragraph"><p>In general, URLs contain information about the transport protocol, the
841 address of the remote server, and the path to the repository.
842 Depending on the transport protocol, some of this information may be
844 <div class=
"paragraph"><p>Git natively supports ssh, git, http, https, ftp, ftps, and rsync
845 protocols. The following syntaxes may be used with them:
</p></div>
846 <div class=
"ulist"><ul>
849 ssh://
[user@
]host.xz
[:port
]/path/to/repo.git/
854 git://host.xz
[:port
]/path/to/repo.git/
859 http
[s
]://host.xz
[:port
]/path/to/repo.git/
864 ftp
[s
]://host.xz
[:port
]/path/to/repo.git/
869 rsync://host.xz/path/to/repo.git/
873 <div class=
"paragraph"><p>An alternative scp-like syntax may also be used with the ssh protocol:
</p></div>
874 <div class=
"ulist"><ul>
877 [user@
]host.xz:path/to/repo.git/
881 <div class=
"paragraph"><p>The ssh and git protocols additionally support ~username expansion:
</p></div>
882 <div class=
"ulist"><ul>
885 ssh://
[user@
]host.xz
[:port
]/~
[user
]/path/to/repo.git/
890 git://host.xz
[:port
]/~
[user
]/path/to/repo.git/
895 [user@
]host.xz:/~
[user
]/path/to/repo.git/
899 <div class=
"paragraph"><p>For local repositories, also supported by git natively, the following
900 syntaxes may be used:
</p></div>
901 <div class=
"ulist"><ul>
909 <a href=
"file:///path/to/repo.git/">file:///path/to/repo.git/
</a>
913 <div class=
"paragraph"><p>These two syntaxes are mostly equivalent, except when cloning, when
914 the former implies --local option. See
<a href=
"git-clone.html">git-clone(
1)
</a> for
916 <div class=
"paragraph"><p>When git doesn
’t know how to handle a certain transport protocol, it
917 attempts to use the
<em>remote-
<transport
></em> remote helper, if one
918 exists. To explicitly request a remote helper, the following syntax
919 may be used:
</p></div>
920 <div class=
"ulist"><ul>
923 <transport
>::
<address
>
927 <div class=
"paragraph"><p>where
<address
> may be a path, a server and path, or an arbitrary
928 URL-like string recognized by the specific remote helper being
929 invoked. See
<a href=
"git-remote-helpers.html">git-remote-helpers(
1)
</a> for details.
</p></div>
930 <div class=
"paragraph"><p>If there are a large number of similarly-named remote repositories and
931 you want to use a different format for them (such that the URLs you
932 use will be rewritten into URLs that work), you can create a
933 configuration section of the form:
</p></div>
934 <div class=
"listingblock">
935 <div class=
"content">
936 <pre><tt> [url
"<actual url base>"]
937 insteadOf =
<other url base
></tt></pre>
939 <div class=
"paragraph"><p>For example, with this:
</p></div>
940 <div class=
"listingblock">
941 <div class=
"content">
942 <pre><tt> [url
"git://git.host.xz/"]
943 insteadOf = host.xz:/path/to/
944 insteadOf = work:
</tt></pre>
946 <div class=
"paragraph"><p>a URL like
"work:repo.git" or like
"host.xz:/path/to/repo.git" will be
947 rewritten in any context that takes a URL to be
"git://git.host.xz/repo.git".
</p></div>
948 <div class=
"paragraph"><p>If you want to rewrite URLs for push only, you can create a
949 configuration section of the form:
</p></div>
950 <div class=
"listingblock">
951 <div class=
"content">
952 <pre><tt> [url
"<actual url base>"]
953 pushInsteadOf =
<other url base
></tt></pre>
955 <div class=
"paragraph"><p>For example, with this:
</p></div>
956 <div class=
"listingblock">
957 <div class=
"content">
958 <pre><tt> [url
"ssh://example.org/"]
959 pushInsteadOf = git://example.org/
</tt></pre>
961 <div class=
"paragraph"><p>a URL like
"git://example.org/path/to/repo.git" will be rewritten to
962 "ssh://example.org/path/to/repo.git" for pushes, but pulls will still
963 use the original URL.
</p></div>
965 <h2 id=
"_remotes_a_id_remotes_a">REMOTES
<a id=
"REMOTES"></a></h2>
966 <div class=
"sectionbody">
967 <div class=
"paragraph"><p>The name of one of the following can be used instead
968 of a URL as
<tt><repository
></tt> argument:
</p></div>
969 <div class=
"ulist"><ul>
972 a remote in the git configuration file:
<tt>$GIT_DIR/config
</tt>,
977 a file in the
<tt>$GIT_DIR/remotes
</tt> directory, or
982 a file in the
<tt>$GIT_DIR/branches
</tt> directory.
986 <div class=
"paragraph"><p>All of these also allow you to omit the refspec from the command line
987 because they each contain a refspec which git will use by default.
</p></div>
988 <h3 id=
"_named_remote_in_configuration_file">Named remote in configuration file
</h3><div style=
"clear:left"></div>
989 <div class=
"paragraph"><p>You can choose to provide the name of a remote which you had previously
990 configured using
<a href=
"git-remote.html">git-remote(
1)
</a>,
<a href=
"git-config.html">git-config(
1)
</a>
991 or even by a manual edit to the
<tt>$GIT_DIR/config
</tt> file. The URL of
992 this remote will be used to access the repository. The refspec
993 of this remote will be used by default when you do
994 not provide a refspec on the command line. The entry in the
995 config file would appear like this:
</p></div>
996 <div class=
"listingblock">
997 <div class=
"content">
998 <pre><tt> [remote
"<name>"]
1000 pushurl =
<pushurl
>
1001 push =
<refspec
>
1002 fetch =
<refspec
></tt></pre>
1004 <div class=
"paragraph"><p>The
<tt><pushurl
></tt> is used for pushes only. It is optional and defaults
1005 to
<tt><url
></tt>.
</p></div>
1006 <h3 id=
"_named_file_in_tt_git_dir_remotes_tt">Named file in
<tt>$GIT_DIR/remotes
</tt></h3><div style=
"clear:left"></div>
1007 <div class=
"paragraph"><p>You can choose to provide the name of a
1008 file in
<tt>$GIT_DIR/remotes
</tt>. The URL
1009 in this file will be used to access the repository. The refspec
1010 in this file will be used as default when you do not
1011 provide a refspec on the command line. This file should have the
1012 following format:
</p></div>
1013 <div class=
"listingblock">
1014 <div class=
"content">
1015 <pre><tt> URL: one of the above URL format
1016 Push:
<refspec
>
1017 Pull:
<refspec
></tt></pre>
1019 <div class=
"paragraph"><p><tt>Push:
</tt> lines are used by
<em>git push
</em> and
1020 <tt>Pull:
</tt> lines are used by
<em>git pull
</em> and
<em>git fetch
</em>.
1021 Multiple
<tt>Push:
</tt> and
<tt>Pull:
</tt> lines may
1022 be specified for additional branch mappings.
</p></div>
1023 <h3 id=
"_named_file_in_tt_git_dir_branches_tt">Named file in
<tt>$GIT_DIR/branches
</tt></h3><div style=
"clear:left"></div>
1024 <div class=
"paragraph"><p>You can choose to provide the name of a
1025 file in
<tt>$GIT_DIR/branches
</tt>.
1026 The URL in this file will be used to access the repository.
1027 This file should have the following format:
</p></div>
1028 <div class=
"listingblock">
1029 <div class=
"content">
1030 <pre><tt> <url
>#
<head
></tt></pre>
1032 <div class=
"paragraph"><p><tt><url
></tt> is required;
<tt>#
<head
></tt> is optional.
</p></div>
1033 <div class=
"paragraph"><p>Depending on the operation, git will use one of the following
1034 refspecs, if you don
’t provide one on the command line.
1035 <tt><branch
></tt> is the name of this file in
<tt>$GIT_DIR/branches
</tt> and
1036 <tt><head
></tt> defaults to
<tt>master
</tt>.
</p></div>
1037 <div class=
"paragraph"><p>git fetch uses:
</p></div>
1038 <div class=
"listingblock">
1039 <div class=
"content">
1040 <pre><tt> refs/heads/
<head
>:refs/heads/
<branch
></tt></pre>
1042 <div class=
"paragraph"><p>git push uses:
</p></div>
1043 <div class=
"listingblock">
1044 <div class=
"content">
1045 <pre><tt> HEAD:refs/heads/
<head
></tt></pre>
1048 <h2 id=
"_output">OUTPUT
</h2>
1049 <div class=
"sectionbody">
1050 <div class=
"paragraph"><p>The output of
"git push" depends on the transport method used; this
1051 section describes the output when pushing over the git protocol (either
1052 locally or via ssh).
</p></div>
1053 <div class=
"paragraph"><p>The status of the push is output in tabular form, with each line
1054 representing the status of a single ref. Each line is of the form:
</p></div>
1055 <div class=
"listingblock">
1056 <div class=
"content">
1057 <pre><tt> <flag
> <summary
> <from
> -
> <to
> (
<reason
>)
</tt></pre>
1059 <div class=
"paragraph"><p>If --porcelain is used, then each line of the output is of the form:
</p></div>
1060 <div class=
"listingblock">
1061 <div class=
"content">
1062 <pre><tt> <flag
> \t
<from
>:
<to
> \t
<summary
> (
<reason
>)
</tt></pre>
1064 <div class=
"paragraph"><p>The status of up-to-date refs is shown only if --porcelain or --verbose
1065 option is used.
</p></div>
1066 <div class=
"dlist"><dl>
1067 <dt class=
"hdlist1">
1072 A single character indicating the status of the ref:
1074 <div class=
"dlist"><dl>
1075 <dt class=
"hdlist1">
1080 for a successfully pushed fast-forward;
1083 <dt class=
"hdlist1">
1088 for a successful forced update;
1091 <dt class=
"hdlist1">
1096 for a successfully deleted ref;
1099 <dt class=
"hdlist1">
1104 for a successfully pushed new ref;
1107 <dt class=
"hdlist1">
1112 for a ref that was rejected or failed to push; and
1115 <dt class=
"hdlist1">
1120 for a ref that was up to date and did not need pushing.
1125 <dt class=
"hdlist1">
1130 For a successfully pushed ref, the summary shows the old and new
1131 values of the ref in a form suitable for using as an argument to
1132 <tt>git log
</tt> (this is
<tt><old
>..
<new
></tt> in most cases, and
1133 <tt><old
>...
<new
></tt> for forced non-fast-forward updates).
1135 <div class=
"paragraph"><p>For a failed update, more details are given:
</p></div>
1136 <div class=
"dlist"><dl>
1137 <dt class=
"hdlist1">
1142 Git did not try to send the ref at all, typically because it
1143 is not a fast-forward and you did not force the update.
1146 <dt class=
"hdlist1">
1151 The remote end refused the update. Usually caused by a hook
1152 on the remote side, or because the remote repository has one
1153 of the following safety options in effect:
1154 <tt>receive.denyCurrentBranch
</tt> (for pushes to the checked out
1155 branch),
<tt>receive.denyNonFastForwards
</tt> (for forced
1156 non-fast-forward updates),
<tt>receive.denyDeletes
</tt> or
1157 <tt>receive.denyDeleteCurrent
</tt>. See
<a href=
"git-config.html">git-config(
1)
</a>.
1160 <dt class=
"hdlist1">
1165 The remote end did not report the successful update of the ref,
1166 perhaps because of a temporary error on the remote side, a
1167 break in the network connection, or other transient error.
1172 <dt class=
"hdlist1">
1177 The name of the local ref being pushed, minus its
1178 <tt>refs/
<type
>/
</tt> prefix. In the case of deletion, the
1179 name of the local ref is omitted.
1182 <dt class=
"hdlist1">
1187 The name of the remote ref being updated, minus its
1188 <tt>refs/
<type
>/
</tt> prefix.
1191 <dt class=
"hdlist1">
1196 A human-readable explanation. In the case of successfully pushed
1197 refs, no explanation is needed. For a failed ref, the reason for
1198 failure is described.
1203 <h2 id=
"_note_about_fast_forwards">Note about fast-forwards
</h2>
1204 <div class=
"sectionbody">
1205 <div class=
"paragraph"><p>When an update changes a branch (or more in general, a ref) that used to
1206 point at commit A to point at another commit B, it is called a
1207 fast-forward update if and only if B is a descendant of A.
</p></div>
1208 <div class=
"paragraph"><p>In a fast-forward update from A to B, the set of commits that the original
1209 commit A built on top of is a subset of the commits the new commit B
1210 builds on top of. Hence, it does not lose any history.
</p></div>
1211 <div class=
"paragraph"><p>In contrast, a non-fast-forward update will lose history. For example,
1212 suppose you and somebody else started at the same commit X, and you built
1213 a history leading to commit B while the other person built a history
1214 leading to commit A. The history looks like this:
</p></div>
1215 <div class=
"listingblock">
1216 <div class=
"content">
1221 <div class=
"paragraph"><p>Further suppose that the other person already pushed changes leading to A
1222 back to the original repository you two obtained the original commit X.
</p></div>
1223 <div class=
"paragraph"><p>The push done by the other person updated the branch that used to point at
1224 commit X to point at commit A. It is a fast-forward.
</p></div>
1225 <div class=
"paragraph"><p>But if you try to push, you will attempt to update the branch (that
1226 now points at A) with commit B. This does
<em>not
</em> fast-forward. If you did
1227 so, the changes introduced by commit A will be lost, because everybody
1228 will now start building on top of B.
</p></div>
1229 <div class=
"paragraph"><p>The command by default does not allow an update that is not a fast-forward
1230 to prevent such loss of history.
</p></div>
1231 <div class=
"paragraph"><p>If you do not want to lose your work (history from X to B) nor the work by
1232 the other person (history from X to A), you would need to first fetch the
1233 history from the repository, create a history that contains changes done
1234 by both parties, and push the result back.
</p></div>
1235 <div class=
"paragraph"><p>You can perform
"git pull", resolve potential conflicts, and
"git push"
1236 the result. A
"git pull" will create a merge commit C between commits A
1238 <div class=
"listingblock">
1239 <div class=
"content">
1244 <div class=
"paragraph"><p>Updating A with the resulting merge commit will fast-forward and your
1245 push will be accepted.
</p></div>
1246 <div class=
"paragraph"><p>Alternatively, you can rebase your change between X and B on top of A,
1247 with
"git pull --rebase", and push the result back. The rebase will
1248 create a new commit D that builds the change between X and B on top of
1250 <div class=
"listingblock">
1251 <div class=
"content">
1256 <div class=
"paragraph"><p>Again, updating A with this commit will fast-forward and your push will be
1258 <div class=
"paragraph"><p>There is another common situation where you may encounter non-fast-forward
1259 rejection when you try to push, and it is possible even when you are
1260 pushing into a repository nobody else pushes into. After you push commit
1261 A yourself (in the first picture in this section), replace it with
"git
1262 commit --amend" to produce commit B, and you try to push it out, because
1263 forgot that you have pushed A out already. In such a case, and only if
1264 you are certain that nobody in the meantime fetched your earlier commit A
1265 (and started building on top of it), you can run
"git push --force" to
1266 overwrite it. In other words,
"git push --force" is a method reserved for
1267 a case where you do mean to lose history.
</p></div>
1269 <h2 id=
"_examples">Examples
</h2>
1270 <div class=
"sectionbody">
1271 <div class=
"dlist"><dl>
1272 <dt class=
"hdlist1">
1277 Works like
<tt>git push
<remote
></tt>, where
<remote
> is the
1278 current branch
’s remote (or
<tt>origin
</tt>, if no remote is
1279 configured for the current branch).
1282 <dt class=
"hdlist1">
1283 <tt>git push origin
</tt>
1287 Without additional configuration, works like
1288 <tt>git push origin :
</tt>.
1290 <div class=
"paragraph"><p>The default behavior of this command when no
<refspec
> is given can be
1291 configured by setting the
<tt>push
</tt> option of the remote.
</p></div>
1292 <div class=
"paragraph"><p>For example, to default to pushing only the current branch to
<tt>origin
</tt>
1293 use
<tt>git config remote.origin.push HEAD
</tt>. Any valid
<refspec
> (like
1294 the ones in the examples below) can be configured as the default for
1295 <tt>git push origin
</tt>.
</p></div>
1297 <dt class=
"hdlist1">
1298 <tt>git push origin :
</tt>
1302 Push
"matching" branches to
<tt>origin
</tt>. See
1303 <refspec
> in the
<a href=
"#OPTIONS">OPTIONS
</a> section above for a
1304 description of
"matching" branches.
1307 <dt class=
"hdlist1">
1308 <tt>git push origin master
</tt>
1312 Find a ref that matches
<tt>master
</tt> in the source repository
1313 (most likely, it would find
<tt>refs/heads/master
</tt>), and update
1314 the same ref (e.g.
<tt>refs/heads/master
</tt>) in
<tt>origin
</tt> repository
1315 with it. If
<tt>master
</tt> did not exist remotely, it would be
1319 <dt class=
"hdlist1">
1320 <tt>git push origin HEAD
</tt>
1324 A handy way to push the current branch to the same name on the
1328 <dt class=
"hdlist1">
1329 <tt>git push origin master:satellite/master dev:satellite/dev
</tt>
1333 Use the source ref that matches
<tt>master
</tt> (e.g.
<tt>refs/heads/master
</tt>)
1334 to update the ref that matches
<tt>satellite/master
</tt> (most probably
1335 <tt>refs/remotes/satellite/master
</tt>) in the
<tt>origin
</tt> repository, then
1336 do the same for
<tt>dev
</tt> and
<tt>satellite/dev
</tt>.
1339 <dt class=
"hdlist1">
1340 <tt>git push origin HEAD:master
</tt>
1344 Push the current branch to the remote ref matching
<tt>master
</tt> in the
1345 <tt>origin
</tt> repository. This form is convenient to push the current
1346 branch without thinking about its local name.
1349 <dt class=
"hdlist1">
1350 <tt>git push origin master:refs/heads/experimental
</tt>
1354 Create the branch
<tt>experimental
</tt> in the
<tt>origin
</tt> repository
1355 by copying the current
<tt>master
</tt> branch. This form is only
1356 needed to create a new branch or tag in the remote repository when
1357 the local name and the remote name are different; otherwise,
1358 the ref name on its own will work.
1361 <dt class=
"hdlist1">
1362 <tt>git push origin :experimental
</tt>
1366 Find a ref that matches
<tt>experimental
</tt> in the
<tt>origin
</tt> repository
1367 (e.g.
<tt>refs/heads/experimental
</tt>), and delete it.
1370 <dt class=
"hdlist1">
1371 <tt>git push origin
+dev:master
</tt>
1375 Update the origin repository
’s master branch with the dev branch,
1376 allowing non-fast-forward updates.
<strong>This can leave unreferenced
1377 commits dangling in the origin repository.
</strong> Consider the
1378 following situation, where a fast-forward is not possible:
1380 <div class=
"listingblock">
1381 <div class=
"content">
1382 <pre><tt> o---o---o---A---B origin/master
1384 X---Y---Z dev
</tt></pre>
1386 <div class=
"paragraph"><p>The above command would change the origin repository to
</p></div>
1387 <div class=
"listingblock">
1388 <div class=
"content">
1389 <pre><tt> A---B (unnamed branch)
1391 o---o---o---X---Y---Z master
</tt></pre>
1393 <div class=
"paragraph"><p>Commits A and B would no longer belong to a branch with a symbolic name,
1394 and so would be unreachable. As such, these commits would be removed by
1395 a
<tt>git gc
</tt> command on the origin repository.
</p></div>
1399 <h2 id=
"_git">GIT
</h2>
1400 <div class=
"sectionbody">
1401 <div class=
"paragraph"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
1404 <div id=
"footnotes"><hr /></div>
1406 <div id=
"footer-text">
1407 Last updated
2011-
09-
21 23:
01:
14 PDT