1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1//EN"
3 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
4 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en">
6 <meta http-equiv=
"Content-Type" content=
"application/xhtml+xml; charset=UTF-8" />
7 <meta name=
"generator" content=
"AsciiDoc 10.2.0" />
8 <title>git-push(
1)
</title>
9 <style type=
"text/css">
10 /* Shared CSS for AsciiDoc xhtml11 and html5 backends */
14 font-family: Georgia,serif;
18 h1, h2, h3, h4, h5, h6,
19 div.title, caption.title,
20 thead, p.table.header,
22 #author, #revnumber, #revdate, #revremark,
24 font-family: Arial,Helvetica,sans-serif;
28 margin:
1em
5%
1em
5%;
33 text-decoration: underline;
49 h1, h2, h3, h4, h5, h6 {
57 border-bottom:
2px solid silver;
77 border:
1px solid silver;
88 ul
> li { color: #aaa; }
89 ul
> li
> * { color: black; }
91 .monospaced, code, pre {
92 font-family:
"Courier New", Courier, monospace;
99 white-space: pre-wrap;
109 #revnumber, #revdate, #revremark {
114 border-top:
2px solid silver;
120 padding-bottom:
0.5em;
124 padding-bottom:
0.5em;
129 margin-bottom:
1.5em;
131 div.imageblock, div.exampleblock, div.verseblock,
132 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
133 div.admonitionblock {
135 margin-bottom:
1.5em;
137 div.admonitionblock {
139 margin-bottom:
2.0em;
144 div.content { /* Block element content. */
148 /* Block element titles. */
149 div.title, caption.title {
154 margin-bottom:
0.5em;
160 td div.title:first-child {
163 div.content div.title:first-child {
166 div.content + div.title {
170 div.sidebarblock
> div.content {
172 border:
1px solid #dddddd;
173 border-left:
4px solid #f0f0f0;
177 div.listingblock
> div.content {
178 border:
1px solid #dddddd;
179 border-left:
5px solid #f0f0f0;
184 div.quoteblock, div.verseblock {
188 border-left:
5px solid #f0f0f0;
192 div.quoteblock
> div.attribution {
197 div.verseblock
> pre.content {
198 font-family: inherit;
201 div.verseblock
> div.attribution {
205 /* DEPRECATED: Pre version
8.2.7 verse style literal block. */
206 div.verseblock + div.attribution {
210 div.admonitionblock .icon {
214 text-decoration: underline;
216 padding-right:
0.5em;
218 div.admonitionblock td.content {
220 border-left:
3px solid #dddddd;
223 div.exampleblock
> div.content {
224 border-left:
3px solid #dddddd;
228 div.imageblock div.content { padding-left:
0; }
229 span.image img { border-style: none; vertical-align: text-bottom; }
230 a.image:visited { color: white; }
234 margin-bottom:
0.8em;
247 list-style-position: outside;
250 list-style-type: decimal;
253 list-style-type: lower-alpha;
256 list-style-type: upper-alpha;
259 list-style-type: lower-roman;
262 list-style-type: upper-roman;
265 div.compact ul, div.compact ol,
266 div.compact p, div.compact p,
267 div.compact div, div.compact div {
269 margin-bottom:
0.1em;
281 margin-bottom:
0.8em;
284 padding-bottom:
15px;
286 dt.hdlist1.strong, td.hdlist1.strong {
292 padding-right:
0.8em;
298 div.hdlist.compact tr {
307 .footnote, .footnoteref {
311 span.footnote, span.footnoteref {
312 vertical-align: super;
316 margin:
20px
0 20px
0;
320 #footnotes div.footnote {
326 border-top:
1px solid silver;
335 padding-right:
0.5em;
336 padding-bottom:
0.3em;
344 #footer-badges { display: none; }
348 margin-bottom:
2.5em;
356 margin-bottom:
0.1em;
359 div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
376 span.aqua { color: aqua; }
377 span.black { color: black; }
378 span.blue { color: blue; }
379 span.fuchsia { color: fuchsia; }
380 span.gray { color: gray; }
381 span.green { color: green; }
382 span.lime { color: lime; }
383 span.maroon { color: maroon; }
384 span.navy { color: navy; }
385 span.olive { color: olive; }
386 span.purple { color: purple; }
387 span.red { color: red; }
388 span.silver { color: silver; }
389 span.teal { color: teal; }
390 span.white { color: white; }
391 span.yellow { color: yellow; }
393 span.aqua-background { background: aqua; }
394 span.black-background { background: black; }
395 span.blue-background { background: blue; }
396 span.fuchsia-background { background: fuchsia; }
397 span.gray-background { background: gray; }
398 span.green-background { background: green; }
399 span.lime-background { background: lime; }
400 span.maroon-background { background: maroon; }
401 span.navy-background { background: navy; }
402 span.olive-background { background: olive; }
403 span.purple-background { background: purple; }
404 span.red-background { background: red; }
405 span.silver-background { background: silver; }
406 span.teal-background { background: teal; }
407 span.white-background { background: white; }
408 span.yellow-background { background: yellow; }
410 span.big { font-size:
2em; }
411 span.small { font-size:
0.6em; }
413 span.underline { text-decoration: underline; }
414 span.overline { text-decoration: overline; }
415 span.line-through { text-decoration: line-through; }
417 div.unbreakable { page-break-inside: avoid; }
427 margin-bottom:
1.5em;
429 div.tableblock
> table {
430 border:
3px solid #
527bbd;
432 thead, p.table.header {
439 /* Because the table frame attribute is overridden by CSS in most browsers. */
440 div.tableblock
> table[
frame=
"void"] {
443 div.tableblock
> table[
frame=
"hsides"] {
444 border-left-style: none;
445 border-right-style: none;
447 div.tableblock
> table[
frame=
"vsides"] {
448 border-top-style: none;
449 border-bottom-style: none;
460 margin-bottom:
1.5em;
462 thead, p.tableblock.header {
473 border-color: #
527bbd;
474 border-collapse: collapse;
476 th.tableblock, td.tableblock {
480 border-color: #
527bbd;
483 table.tableblock.frame-topbot {
484 border-left-style: hidden;
485 border-right-style: hidden;
487 table.tableblock.frame-sides {
488 border-top-style: hidden;
489 border-bottom-style: hidden;
491 table.tableblock.frame-none {
492 border-style: hidden;
495 th.tableblock.halign-left, td.tableblock.halign-left {
498 th.tableblock.halign-center, td.tableblock.halign-center {
501 th.tableblock.halign-right, td.tableblock.halign-right {
505 th.tableblock.valign-top, td.tableblock.valign-top {
508 th.tableblock.valign-middle, td.tableblock.valign-middle {
509 vertical-align: middle;
511 th.tableblock.valign-bottom, td.tableblock.valign-bottom {
512 vertical-align: bottom;
523 padding-bottom:
0.5em;
524 border-top:
2px solid silver;
525 border-bottom:
2px solid silver;
530 body.manpage div.sectionbody {
535 body.manpage div#toc { display: none; }
540 <script type=
"text/javascript">
542 var asciidoc = { // Namespace.
544 /////////////////////////////////////////////////////////////////////
545 // Table Of Contents generator
546 /////////////////////////////////////////////////////////////////////
548 /* Author: Mihai Bazon, September
2002
549 * http://students.infoiasi.ro/~mishoo
551 * Table Of Content generator
554 * Feel free to use this script under the terms of the GNU General Public
555 * License, as long as you do not remove or alter this notice.
558 /* modified by Troy D. Hanson, September
2006. License: GPL */
559 /* modified by Stuart Rackham,
2006,
2009. License: GPL */
562 toc: function (toclevels) {
564 function getText(el) {
566 for (var i = el.firstChild; i != null; i = i.nextSibling) {
567 if (i.nodeType ==
3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
569 else if (i.firstChild != null)
575 function TocEntry(el, text, toclevel) {
578 this.toclevel = toclevel;
581 function tocEntries(el, toclevels) {
582 var result = new Array;
583 var re = new RegExp('[hH]([
1-'+(toclevels+
1)+'])');
584 // Function that scans the DOM tree for header elements (the DOM2
585 // nodeIterator API would be a better technique but not supported by all
587 var iterate = function (el) {
588 for (var i = el.firstChild; i != null; i = i.nextSibling) {
589 if (i.nodeType ==
1 /* Node.ELEMENT_NODE */) {
590 var mo = re.exec(i.tagName);
591 if (mo && (i.getAttribute(
"class") || i.getAttribute(
"className")) !=
"float") {
592 result[result.length] = new TocEntry(i, getText(i), mo[
1]-
1);
602 var toc = document.getElementById(
"toc");
607 // Delete existing TOC entries in case we're reloading the TOC.
608 var tocEntriesToRemove = [];
610 for (i =
0; i < toc.childNodes.length; i++) {
611 var entry = toc.childNodes[i];
612 if (entry.nodeName.toLowerCase() == 'div'
613 && entry.getAttribute(
"class")
614 && entry.getAttribute(
"class").match(/^toclevel/))
615 tocEntriesToRemove.push(entry);
617 for (i =
0; i < tocEntriesToRemove.length; i++) {
618 toc.removeChild(tocEntriesToRemove[i]);
621 // Rebuild TOC entries.
622 var entries = tocEntries(document.getElementById(
"content"), toclevels);
623 for (var i =
0; i < entries.length; ++i) {
624 var entry = entries[i];
625 if (entry.element.id ==
"")
626 entry.element.id =
"_toc_" + i;
627 var a = document.createElement(
"a");
628 a.href =
"#" + entry.element.id;
629 a.appendChild(document.createTextNode(entry.text));
630 var div = document.createElement(
"div");
632 div.className =
"toclevel" + entry.toclevel;
633 toc.appendChild(div);
635 if (entries.length ==
0)
636 toc.parentNode.removeChild(toc);
640 /////////////////////////////////////////////////////////////////////
641 // Footnotes generator
642 /////////////////////////////////////////////////////////////////////
644 /* Based on footnote generation code from:
645 * http://www.brandspankingnew.net/archive/
2005/
07/format_footnote.html
648 footnotes: function () {
649 // Delete existing footnote entries in case we're reloading the footnodes.
651 var noteholder = document.getElementById(
"footnotes");
655 var entriesToRemove = [];
656 for (i =
0; i < noteholder.childNodes.length; i++) {
657 var entry = noteholder.childNodes[i];
658 if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute(
"class") ==
"footnote")
659 entriesToRemove.push(entry);
661 for (i =
0; i < entriesToRemove.length; i++) {
662 noteholder.removeChild(entriesToRemove[i]);
665 // Rebuild footnote entries.
666 var cont = document.getElementById(
"content");
667 var spans = cont.getElementsByTagName(
"span");
670 for (i=
0; i
<spans.length; i++) {
671 if (spans[i].className ==
"footnote") {
673 var note = spans[i].getAttribute(
"data-note");
675 // Use [\s\S] in place of . so multi-line matches work.
676 // Because JavaScript has no s (dotall) regex flag.
677 note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[
1];
679 "[<a id='_footnoteref_" + n +
"' href='#_footnote_" + n +
680 "' title='View footnote' class='footnote'>" + n +
"</a>]";
681 spans[i].setAttribute(
"data-note", note);
683 noteholder.innerHTML +=
684 "<div class='footnote' id='_footnote_" + n +
"'>" +
685 "<a href='#_footnoteref_" + n +
"' title='Return to text'>" +
686 n +
"</a>. " + note +
"</div>";
687 var id =spans[i].getAttribute(
"id");
688 if (id != null) refs[
"#"+id] = n;
692 noteholder.parentNode.removeChild(noteholder);
694 // Process footnoterefs.
695 for (i=
0; i
<spans.length; i++) {
696 if (spans[i].className ==
"footnoteref") {
697 var href = spans[i].getElementsByTagName(
"a")[
0].getAttribute(
"href");
698 href = href.match(/#.*/)[
0]; // Because IE return full URL.
701 "[<a href='#_footnote_" + n +
702 "' title='View footnote' class='footnote'>" + n +
"</a>]";
708 install: function(toclevels) {
711 function reinstall() {
712 asciidoc.footnotes();
714 asciidoc.toc(toclevels);
718 function reinstallAndRemoveTimer() {
719 clearInterval(timerId);
723 timerId = setInterval(reinstall,
500);
724 if (document.addEventListener)
725 document.addEventListener(
"DOMContentLoaded", reinstallAndRemoveTimer, false);
727 window.onload = reinstallAndRemoveTimer;
735 <body class=
"manpage">
738 git-push(
1) Manual Page
741 <div class=
"sectionbody">
743 Update remote refs along with associated objects
749 <h2 id=
"_synopsis">SYNOPSIS
</h2>
750 <div class=
"sectionbody">
751 <div class=
"verseblock">
752 <pre class=
"content"><em>git push
</em> [--all | --mirror | --tags] [--follow-tags] [--atomic] [-n | --dry-run] [--receive-pack=
<git-receive-pack
>]
753 [--repo=
<repository
>] [-f | --force] [-d | --delete] [--prune] [-v | --verbose]
754 [-u | --set-upstream] [-o
<string
> | --push-option=
<string
>]
755 [--[no-]signed|--signed=(true|false|if-asked)]
756 [--force-with-lease[=
<refname
>[:
<expect
>]] [--force-if-includes]]
757 [--no-verify] [
<repository
> [
<refspec
>…]]
</pre>
758 <div class=
"attribution">
763 <h2 id=
"_description">DESCRIPTION
</h2>
764 <div class=
"sectionbody">
765 <div class=
"paragraph"><p>Updates remote refs using local refs, while sending objects
766 necessary to complete the given refs.
</p></div>
767 <div class=
"paragraph"><p>You can make interesting things happen to a repository
768 every time you push into it, by setting up
<em>hooks
</em> there. See
769 documentation for
<a href=
"git-receive-pack.html">git-receive-pack(
1)
</a>.
</p></div>
770 <div class=
"paragraph"><p>When the command line does not specify where to push with the
771 <code><repository
></code> argument,
<code>branch.*.remote
</code> configuration for the
772 current branch is consulted to determine where to push. If the
773 configuration is missing, it defaults to
<em>origin
</em>.
</p></div>
774 <div class=
"paragraph"><p>When the command line does not specify what to push with
<code><refspec
>...
</code>
775 arguments or
<code>--all
</code>,
<code>--mirror
</code>,
<code>--tags
</code> options, the command finds
776 the default
<code><refspec
></code> by consulting
<code>remote.*.push
</code> configuration,
777 and if it is not found, honors
<code>push.default
</code> configuration to decide
778 what to push (See
<a href=
"git-config.html">git-config(
1)
</a> for the meaning of
<code>push.default
</code>).
</p></div>
779 <div class=
"paragraph"><p>When neither the command-line nor the configuration specify what to
780 push, the default behavior is used, which corresponds to the
<code>simple
</code>
781 value for
<code>push.default
</code>: the current branch is pushed to the
782 corresponding upstream branch, but as a safety measure, the push is
783 aborted if the upstream branch does not have the same name as the
788 <h2 id=
"_options_a_id_options_a">OPTIONS
<a id=
"OPTIONS"></a></h2>
789 <div class=
"sectionbody">
790 <div class=
"dlist"><dl>
796 The
"remote" repository that is destination of a push
797 operation. This parameter can be either a URL
798 (see the section
<a href=
"#URLS">GIT URLS
</a> below) or the name
799 of a remote (see the section
<a href=
"#REMOTES">REMOTES
</a> below).
803 <refspec
>…
807 Specify what destination ref to update with what source object.
808 The format of a
<refspec
> parameter is an optional plus
809 <code>+
</code>, followed by the source object
<src
>, followed
810 by a colon
<code>:
</code>, followed by the destination ref
<dst
>.
812 <div class=
"paragraph"><p>The
<src
> is often the name of the branch you would want to push, but
813 it can be any arbitrary
"SHA-1 expression", such as
<code>master~
4</code> or
814 <code>HEAD
</code> (see
<a href=
"gitrevisions.html">gitrevisions(
7)
</a>).
</p></div>
815 <div class=
"paragraph"><p>The
<dst
> tells which ref on the remote side is updated with this
816 push. Arbitrary expressions cannot be used here, an actual ref must
818 If
<code>git push [
<repository
>]
</code> without any
<code><refspec
></code> argument is set to
819 update some ref at the destination with
<code><src
></code> with
820 <code>remote.
<repository
>.push
</code> configuration variable,
<code>:
<dst
></code> part can
821 be omitted
—such a push will update a ref that
<code><src
></code> normally updates
822 without any
<code><refspec
></code> on the command line. Otherwise, missing
823 <code>:
<dst
></code> means to update the same ref as the
<code><src
></code>.
</p></div>
824 <div class=
"paragraph"><p>If
<dst
> doesn
’t start with
<code>refs/
</code> (e.g.
<code>refs/heads/master
</code>) we will
825 try to infer where in
<code>refs/*
</code> on the destination
<repository
> it
826 belongs based on the type of
<src
> being pushed and whether
<dst
>
827 is ambiguous.
</p></div>
828 <div class=
"openblock">
829 <div class=
"content">
830 <div class=
"ulist"><ul>
833 If
<dst
> unambiguously refers to a ref on the
<repository
> remote,
834 then push to that ref.
839 If
<src
> resolves to a ref starting with refs/heads/ or refs/tags/,
840 then prepend that to
<dst
>.
845 Other ambiguity resolutions might be added in the future, but for
846 now any other cases will error out with an error indicating what we
847 tried, and depending on the
<code>advice.pushUnqualifiedRefname
</code>
848 configuration (see
<a href=
"git-config.html">git-config(
1)
</a>) suggest what refs/
849 namespace you may have wanted to push to.
854 <div class=
"paragraph"><p>The object referenced by
<src
> is used to update the
<dst
> reference
855 on the remote side. Whether this is allowed depends on where in
856 <code>refs/*
</code> the
<dst
> reference lives as described in detail below, in
857 those sections
"update" means any modifications except deletes, which
858 as noted after the next few sections are treated differently.
</p></div>
859 <div class=
"paragraph"><p>The
<code>refs/heads/*
</code> namespace will only accept commit objects, and
860 updates only if they can be fast-forwarded.
</p></div>
861 <div class=
"paragraph"><p>The
<code>refs/tags/*
</code> namespace will accept any kind of object (as
862 commits, trees and blobs can be tagged), and any updates to them will
863 be rejected.
</p></div>
864 <div class=
"paragraph"><p>It
’s possible to push any type of object to any namespace outside of
865 <code>refs/{tags,heads}/*
</code>. In the case of tags and commits, these will be
866 treated as if they were the commits inside
<code>refs/heads/*
</code> for the
867 purposes of whether the update is allowed.
</p></div>
868 <div class=
"paragraph"><p>I.e. a fast-forward of commits and tags outside
<code>refs/{tags,heads}/*
</code>
869 is allowed, even in cases where what
’s being fast-forwarded is not a
870 commit, but a tag object which happens to point to a new commit which
871 is a fast-forward of the commit the last tag (or commit) it
’s
872 replacing. Replacing a tag with an entirely different tag is also
873 allowed, if it points to the same commit, as well as pushing a peeled
874 tag, i.e. pushing the commit that existing tag object points to, or a
875 new tag object which an existing commit points to.
</p></div>
876 <div class=
"paragraph"><p>Tree and blob objects outside of
<code>refs/{tags,heads}/*
</code> will be treated
877 the same way as if they were inside
<code>refs/tags/*
</code>, any update of them
878 will be rejected.
</p></div>
879 <div class=
"paragraph"><p>All of the rules described above about what
’s not allowed as an update
880 can be overridden by adding an the optional leading
<code>+
</code> to a refspec
881 (or using
<code>--force
</code> command line option). The only exception to this
882 is that no amount of forcing will make the
<code>refs/heads/*
</code> namespace
883 accept a non-commit object. Hooks and configuration can also override
884 or amend these rules, see e.g.
<code>receive.denyNonFastForwards
</code> in
885 <a href=
"git-config.html">git-config(
1)
</a> and
<code>pre-receive
</code> and
<code>update
</code> in
886 <a href=
"githooks.html">githooks(
5)
</a>.
</p></div>
887 <div class=
"paragraph"><p>Pushing an empty
<src
> allows you to delete the
<dst
> ref from the
888 remote repository. Deletions are always accepted without a leading
<code>+
</code>
889 in the refspec (or
<code>--force
</code>), except when forbidden by configuration
890 or hooks. See
<code>receive.denyDeletes
</code> in
<a href=
"git-config.html">git-config(
1)
</a> and
891 <code>pre-receive
</code> and
<code>update
</code> in
<a href=
"githooks.html">githooks(
5)
</a>.
</p></div>
892 <div class=
"paragraph"><p>The special refspec
<code>:
</code> (or
<code>+:
</code> to allow non-fast-forward updates)
893 directs Git to push
"matching" branches: for every branch that exists on
894 the local side, the remote side is updated if a branch of the same name
895 already exists on the remote side.
</p></div>
896 <div class=
"paragraph"><p><code>tag
<tag
></code> means the same as
<code>refs/tags/
<tag
>:refs/tags/
<tag
></code>.
</p></div>
903 Push all branches (i.e. refs under
<code>refs/heads/
</code>); cannot be
904 used with other
<refspec
>.
912 Remove remote branches that don
’t have a local counterpart. For example
913 a remote branch
<code>tmp
</code> will be removed if a local branch with the same
914 name doesn
’t exist any more. This also respects refspecs, e.g.
915 <code>git push --prune remote refs/heads/*:refs/tmp/*
</code> would
916 make sure that remote
<code>refs/tmp/foo
</code> will be removed if
<code>refs/heads/foo
</code>
925 Instead of naming each ref to push, specifies that all
926 refs under
<code>refs/
</code> (which includes but is not
927 limited to
<code>refs/heads/
</code>,
<code>refs/remotes/
</code>, and
<code>refs/tags/
</code>)
928 be mirrored to the remote repository. Newly created local
929 refs will be pushed to the remote end, locally updated refs
930 will be force updated on the remote end, and deleted refs
931 will be removed from the remote end. This is the default
932 if the configuration option
<code>remote.
<remote
>.mirror
</code> is
944 Do everything except actually send the updates.
952 Produce machine-readable output. The output status line for each ref
953 will be tab-separated and sent to stdout instead of stderr. The full
954 symbolic names of the refs will be given.
965 All listed refs are deleted from the remote repository. This is
966 the same as prefixing all refs with a colon.
974 All refs under
<code>refs/tags
</code> are pushed, in
975 addition to refspecs explicitly listed on the command
984 Push all the refs that would be pushed without this option,
985 and also push annotated tags in
<code>refs/tags
</code> that are missing
986 from the remote but are pointing at commit-ish that are
987 reachable from the refs being pushed. This can also be specified
988 with configuration variable
<code>push.followTags
</code>. For more
989 information, see
<code>push.followTags
</code> in
<a href=
"git-config.html">git-config(
1)
</a>.
996 --signed=(true|false|if-asked)
1000 GPG-sign the push request to update refs on the receiving
1001 side, to allow it to be checked by the hooks and/or be
1002 logged. If
<code>false
</code> or
<code>--no-signed
</code>, no signing will be
1003 attempted. If
<code>true
</code> or
<code>--signed
</code>, the push will fail if the
1004 server does not support signed pushes. If set to
<code>if-asked
</code>,
1005 sign if and only if the server supports signed pushes. The push
1006 will also fail if the actual call to
<code>gpg --sign
</code> fails. See
1007 <a href=
"git-receive-pack.html">git-receive-pack(
1)
</a> for the details on the receiving end.
1010 <dt class=
"hdlist1">
1015 Use an atomic transaction on the remote side if available.
1016 Either all refs are updated, or on error, no refs are updated.
1017 If the server does not support atomic pushes the push will fail.
1020 <dt class=
"hdlist1">
1023 <dt class=
"hdlist1">
1024 --push-option=
<option
>
1028 Transmit the given string to the server, which passes them to
1029 the pre-receive as well as the post-receive hook. The given string
1030 must not contain a NUL or LF character.
1031 When multiple
<code>--push-option=
<option
></code> are given, they are
1032 all sent to the other side in the order listed on the
1034 When no
<code>--push-option=
<option
></code> is given from the command
1035 line, the values of configuration variable
<code>push.pushOption
</code>
1039 <dt class=
"hdlist1">
1040 --receive-pack=
<git-receive-pack
>
1042 <dt class=
"hdlist1">
1043 --exec=
<git-receive-pack
>
1047 Path to the
<em>git-receive-pack
</em> program on the remote
1048 end. Sometimes useful when pushing to a remote
1049 repository over ssh, and you do not have the program in
1050 a directory on the default $PATH.
1053 <dt class=
"hdlist1">
1054 --[no-]force-with-lease
1056 <dt class=
"hdlist1">
1057 --force-with-lease=
<refname
>
1059 <dt class=
"hdlist1">
1060 --force-with-lease=
<refname
>:
<expect
>
1064 Usually,
"git push" refuses to update a remote ref that is
1065 not an ancestor of the local ref used to overwrite it.
1067 <div class=
"paragraph"><p>This option overrides this restriction if the current value of the
1068 remote ref is the expected value.
"git push" fails otherwise.
</p></div>
1069 <div class=
"paragraph"><p>Imagine that you have to rebase what you have already published.
1070 You will have to bypass the
"must fast-forward" rule in order to
1071 replace the history you originally published with the rebased history.
1072 If somebody else built on top of your original history while you are
1073 rebasing, the tip of the branch at the remote may advance with their
1074 commit, and blindly pushing with
<code>--force
</code> will lose their work.
</p></div>
1075 <div class=
"paragraph"><p>This option allows you to say that you expect the history you are
1076 updating is what you rebased and want to replace. If the remote ref
1077 still points at the commit you specified, you can be sure that no
1078 other people did anything to the ref. It is like taking a
"lease" on
1079 the ref without explicitly locking it, and the remote ref is updated
1080 only if the
"lease" is still valid.
</p></div>
1081 <div class=
"paragraph"><p><code>--force-with-lease
</code> alone, without specifying the details, will protect
1082 all remote refs that are going to be updated by requiring their
1083 current value to be the same as the remote-tracking branch we have
1085 <div class=
"paragraph"><p><code>--force-with-lease=
<refname
></code>, without specifying the expected value, will
1086 protect the named ref (alone), if it is going to be updated, by
1087 requiring its current value to be the same as the remote-tracking
1088 branch we have for it.
</p></div>
1089 <div class=
"paragraph"><p><code>--force-with-lease=
<refname
>:
<expect
></code> will protect the named ref (alone),
1090 if it is going to be updated, by requiring its current value to be
1091 the same as the specified value
<code><expect
></code> (which is allowed to be
1092 different from the remote-tracking branch we have for the refname,
1093 or we do not even have to have such a remote-tracking branch when
1094 this form is used). If
<code><expect
></code> is the empty string, then the named ref
1095 must not already exist.
</p></div>
1096 <div class=
"paragraph"><p>Note that all forms other than
<code>--force-with-lease=
<refname
>:
<expect
></code>
1097 that specifies the expected current value of the ref explicitly are
1098 still experimental and their semantics may change as we gain experience
1099 with this feature.
</p></div>
1100 <div class=
"paragraph"><p>"--no-force-with-lease" will cancel all the previous --force-with-lease on the
1101 command line.
</p></div>
1102 <div class=
"paragraph"><p>A general note on safety: supplying this option without an expected
1103 value, i.e. as
<code>--force-with-lease
</code> or
<code>--force-with-lease=
<refname
></code>
1104 interacts very badly with anything that implicitly runs
<code>git fetch
</code> on
1105 the remote to be pushed to in the background, e.g.
<code>git fetch origin
</code>
1106 on your repository in a cronjob.
</p></div>
1107 <div class=
"paragraph"><p>The protection it offers over
<code>--force
</code> is ensuring that subsequent
1108 changes your work wasn
’t based on aren
’t clobbered, but this is
1109 trivially defeated if some background process is updating refs in the
1110 background. We don
’t have anything except the remote tracking info to
1111 go by as a heuristic for refs you
’re expected to have seen
& are
1112 willing to clobber.
</p></div>
1113 <div class=
"paragraph"><p>If your editor or some other system is running
<code>git fetch
</code> in the
1114 background for you a way to mitigate this is to simply set up another
1116 <div class=
"literalblock">
1117 <div class=
"content">
1118 <pre><code>git remote add origin-push $(git config remote.origin.url)
1119 git fetch origin-push
</code></pre>
1121 <div class=
"paragraph"><p>Now when the background process runs
<code>git fetch origin
</code> the references
1122 on
<code>origin-push
</code> won
’t be updated, and thus commands like:
</p></div>
1123 <div class=
"literalblock">
1124 <div class=
"content">
1125 <pre><code>git push --force-with-lease origin-push
</code></pre>
1127 <div class=
"paragraph"><p>Will fail unless you manually run
<code>git fetch origin-push
</code>. This method
1128 is of course entirely defeated by something that runs
<code>git fetch
1129 --all
</code>, in that case you
’d need to either disable it or do something
1130 more tedious like:
</p></div>
1131 <div class=
"literalblock">
1132 <div class=
"content">
1133 <pre><code>git fetch # update 'master' from remote
1134 git tag base master # mark our base point
1135 git rebase -i master # rewrite some commits
1136 git push --force-with-lease=master:base master:master
</code></pre>
1138 <div class=
"paragraph"><p>I.e. create a
<code>base
</code> tag for versions of the upstream code that you
’ve
1139 seen and are willing to overwrite, then rewrite history, and finally
1140 force push changes to
<code>master
</code> if the remote version is still at
1141 <code>base
</code>, regardless of what your local
<code>remotes/origin/master
</code> has been
1142 updated to in the background.
</p></div>
1143 <div class=
"paragraph"><p>Alternatively, specifying
<code>--force-if-includes
</code> as an ancillary option
1144 along with
<code>--force-with-lease[=
<refname
>]
</code> (i.e., without saying what
1145 exact commit the ref on the remote side must be pointing at, or which
1146 refs on the remote side are being protected) at the time of
"push" will
1147 verify if updates from the remote-tracking refs that may have been
1148 implicitly updated in the background are integrated locally before
1149 allowing a forced update.
</p></div>
1151 <dt class=
"hdlist1">
1154 <dt class=
"hdlist1">
1159 Usually, the command refuses to update a remote ref that is
1160 not an ancestor of the local ref used to overwrite it.
1161 Also, when
<code>--force-with-lease
</code> option is used, the command refuses
1162 to update a remote ref whose current value does not match
1165 <div class=
"paragraph"><p>This flag disables these checks, and can cause the remote repository
1166 to lose commits; use it with care.
</p></div>
1167 <div class=
"paragraph"><p>Note that
<code>--force
</code> applies to all the refs that are pushed, hence
1168 using it with
<code>push.default
</code> set to
<code>matching
</code> or with multiple push
1169 destinations configured with
<code>remote.*.push
</code> may overwrite refs
1170 other than the current branch (including local refs that are
1171 strictly behind their remote counterpart). To force a push to only
1172 one branch, use a
<code>+
</code> in front of the refspec to push (e.g
<code>git push
1173 origin +master
</code> to force a push to the
<code>master
</code> branch). See the
1174 <code><refspec
>...
</code> section above for details.
</p></div>
1176 <dt class=
"hdlist1">
1177 --[no-]force-if-includes
1181 Force an update only if the tip of the remote-tracking ref
1182 has been integrated locally.
1184 <div class=
"paragraph"><p>This option enables a check that verifies if the tip of the
1185 remote-tracking ref is reachable from one of the
"reflog" entries of
1186 the local branch based in it for a rewrite. The check ensures that any
1187 updates from the remote have been incorporated locally by rejecting the
1188 forced update if that is not the case.
</p></div>
1189 <div class=
"paragraph"><p>If the option is passed without specifying
<code>--force-with-lease
</code>, or
1190 specified along with
<code>--force-with-lease=
<refname
>:
<expect
></code>, it is
1191 a
"no-op".
</p></div>
1192 <div class=
"paragraph"><p>Specifying
<code>--no-force-if-includes
</code> disables this behavior.
</p></div>
1194 <dt class=
"hdlist1">
1195 --repo=
<repository
>
1199 This option is equivalent to the
<repository
> argument. If both
1200 are specified, the command-line argument takes precedence.
1203 <dt class=
"hdlist1">
1206 <dt class=
"hdlist1">
1211 For every branch that is up to date or successfully pushed, add
1212 upstream (tracking) reference, used by argument-less
1213 <a href=
"git-pull.html">git-pull(
1)
</a> and other commands. For more information,
1214 see
<code>branch.
<name
>.merge
</code> in
<a href=
"git-config.html">git-config(
1)
</a>.
1217 <dt class=
"hdlist1">
1222 These options are passed to
<a href=
"git-send-pack.html">git-send-pack(
1)
</a>. A thin transfer
1223 significantly reduces the amount of sent data when the sender and
1224 receiver share many of the same objects in common. The default is
1225 <code>--thin
</code>.
1228 <dt class=
"hdlist1">
1231 <dt class=
"hdlist1">
1236 Suppress all output, including the listing of updated refs,
1237 unless an error occurs. Progress is not reported to the standard
1241 <dt class=
"hdlist1">
1244 <dt class=
"hdlist1">
1252 <dt class=
"hdlist1">
1257 Progress status is reported on the standard error stream
1258 by default when it is attached to a terminal, unless -q
1259 is specified. This flag forces progress status even if the
1260 standard error stream is not directed to a terminal.
1263 <dt class=
"hdlist1">
1264 --no-recurse-submodules
1266 <dt class=
"hdlist1">
1267 --recurse-submodules=check|on-demand|only|no
1271 May be used to make sure all submodule commits used by the
1272 revisions to be pushed are available on a remote-tracking branch.
1273 If
<em>check
</em> is used Git will verify that all submodule commits that
1274 changed in the revisions to be pushed are available on at least one
1275 remote of the submodule. If any commits are missing the push will
1276 be aborted and exit with non-zero status. If
<em>on-demand
</em> is used
1277 all submodules that changed in the revisions to be pushed will be
1278 pushed. If on-demand was not able to push all necessary revisions it will
1279 also be aborted and exit with non-zero status. If
<em>only
</em> is used all
1280 submodules will be recursively pushed while the superproject is left
1281 unpushed. A value of
<em>no
</em> or using
<code>--no-recurse-submodules
</code> can be used
1282 to override the push.recurseSubmodules configuration variable when no
1283 submodule recursion is required.
1286 <dt class=
"hdlist1">
1291 Toggle the pre-push hook (see
<a href=
"githooks.html">githooks(
5)
</a>). The
1292 default is --verify, giving the hook a chance to prevent the
1293 push. With --no-verify, the hook is bypassed completely.
1296 <dt class=
"hdlist1">
1299 <dt class=
"hdlist1">
1304 Use IPv4 addresses only, ignoring IPv6 addresses.
1307 <dt class=
"hdlist1">
1310 <dt class=
"hdlist1">
1315 Use IPv6 addresses only, ignoring IPv4 addresses.
1322 <h2 id=
"_git_urls_a_id_urls_a">GIT URLS
<a id=
"URLS"></a></h2>
1323 <div class=
"sectionbody">
1324 <div class=
"paragraph"><p>In general, URLs contain information about the transport protocol, the
1325 address of the remote server, and the path to the repository.
1326 Depending on the transport protocol, some of this information may be
1328 <div class=
"paragraph"><p>Git supports ssh, git, http, and https protocols (in addition, ftp,
1329 and ftps can be used for fetching, but this is inefficient and
1330 deprecated; do not use it).
</p></div>
1331 <div class=
"paragraph"><p>The native transport (i.e. git:// URL) does no authentication and
1332 should be used with caution on unsecured networks.
</p></div>
1333 <div class=
"paragraph"><p>The following syntaxes may be used with them:
</p></div>
1334 <div class=
"ulist"><ul>
1337 ssh://
[user@
]host.xz
[:port
]/path/to/repo.git/
1342 git://host.xz
[:port
]/path/to/repo.git/
1347 http
[s
]://host.xz
[:port
]/path/to/repo.git/
1352 ftp
[s
]://host.xz
[:port
]/path/to/repo.git/
1356 <div class=
"paragraph"><p>An alternative scp-like syntax may also be used with the ssh protocol:
</p></div>
1357 <div class=
"ulist"><ul>
1360 [user@
]host.xz:path/to/repo.git/
1364 <div class=
"paragraph"><p>This syntax is only recognized if there are no slashes before the
1365 first colon. This helps differentiate a local path that contains a
1366 colon. For example the local path
<code>foo:bar
</code> could be specified as an
1367 absolute path or
<code>./foo:bar
</code> to avoid being misinterpreted as an ssh
1369 <div class=
"paragraph"><p>The ssh and git protocols additionally support ~username expansion:
</p></div>
1370 <div class=
"ulist"><ul>
1373 ssh://
[user@
]host.xz
[:port
]/~
[user
]/path/to/repo.git/
1378 git://host.xz
[:port
]/~
[user
]/path/to/repo.git/
1383 [user@
]host.xz:/~
[user
]/path/to/repo.git/
1387 <div class=
"paragraph"><p>For local repositories, also supported by Git natively, the following
1388 syntaxes may be used:
</p></div>
1389 <div class=
"ulist"><ul>
1397 file:///path/to/repo.git/
1401 <div class=
"paragraph"><p>These two syntaxes are mostly equivalent, except when cloning, when
1402 the former implies --local option. See
<a href=
"git-clone.html">git-clone(
1)
</a> for
1404 <div class=
"paragraph"><p><em>git clone
</em>,
<em>git fetch
</em> and
<em>git pull
</em>, but not
<em>git push
</em>, will also
1405 accept a suitable bundle file. See
<a href=
"git-bundle.html">git-bundle(
1)
</a>.
</p></div>
1406 <div class=
"paragraph"><p>When Git doesn
’t know how to handle a certain transport protocol, it
1407 attempts to use the
<em>remote-
<transport
></em> remote helper, if one
1408 exists. To explicitly request a remote helper, the following syntax
1409 may be used:
</p></div>
1410 <div class=
"ulist"><ul>
1413 <transport
>::
<address
>
1417 <div class=
"paragraph"><p>where
<address
> may be a path, a server and path, or an arbitrary
1418 URL-like string recognized by the specific remote helper being
1419 invoked. See
<a href=
"gitremote-helpers.html">gitremote-helpers(
7)
</a> for details.
</p></div>
1420 <div class=
"paragraph"><p>If there are a large number of similarly-named remote repositories and
1421 you want to use a different format for them (such that the URLs you
1422 use will be rewritten into URLs that work), you can create a
1423 configuration section of the form:
</p></div>
1424 <div class=
"listingblock">
1425 <div class=
"content">
1426 <pre><code> [url
"<actual url base>"]
1427 insteadOf =
<other url base
></code></pre>
1429 <div class=
"paragraph"><p>For example, with this:
</p></div>
1430 <div class=
"listingblock">
1431 <div class=
"content">
1432 <pre><code> [url
"git://git.host.xz/"]
1433 insteadOf = host.xz:/path/to/
1434 insteadOf = work:
</code></pre>
1436 <div class=
"paragraph"><p>a URL like
"work:repo.git" or like
"host.xz:/path/to/repo.git" will be
1437 rewritten in any context that takes a URL to be
"git://git.host.xz/repo.git".
</p></div>
1438 <div class=
"paragraph"><p>If you want to rewrite URLs for push only, you can create a
1439 configuration section of the form:
</p></div>
1440 <div class=
"listingblock">
1441 <div class=
"content">
1442 <pre><code> [url
"<actual url base>"]
1443 pushInsteadOf =
<other url base
></code></pre>
1445 <div class=
"paragraph"><p>For example, with this:
</p></div>
1446 <div class=
"listingblock">
1447 <div class=
"content">
1448 <pre><code> [url
"ssh://example.org/"]
1449 pushInsteadOf = git://example.org/
</code></pre>
1451 <div class=
"paragraph"><p>a URL like
"git://example.org/path/to/repo.git" will be rewritten to
1452 "ssh://example.org/path/to/repo.git" for pushes, but pulls will still
1453 use the original URL.
</p></div>
1457 <h2 id=
"_remotes_a_id_remotes_a">REMOTES
<a id=
"REMOTES"></a></h2>
1458 <div class=
"sectionbody">
1459 <div class=
"paragraph"><p>The name of one of the following can be used instead
1460 of a URL as
<code><repository
></code> argument:
</p></div>
1461 <div class=
"ulist"><ul>
1464 a remote in the Git configuration file:
<code>$GIT_DIR/config
</code>,
1469 a file in the
<code>$GIT_DIR/remotes
</code> directory, or
1474 a file in the
<code>$GIT_DIR/branches
</code> directory.
1478 <div class=
"paragraph"><p>All of these also allow you to omit the refspec from the command line
1479 because they each contain a refspec which git will use by default.
</p></div>
1481 <h3 id=
"_named_remote_in_configuration_file">Named remote in configuration file
</h3>
1482 <div class=
"paragraph"><p>You can choose to provide the name of a remote which you had previously
1483 configured using
<a href=
"git-remote.html">git-remote(
1)
</a>,
<a href=
"git-config.html">git-config(
1)
</a>
1484 or even by a manual edit to the
<code>$GIT_DIR/config
</code> file. The URL of
1485 this remote will be used to access the repository. The refspec
1486 of this remote will be used by default when you do
1487 not provide a refspec on the command line. The entry in the
1488 config file would appear like this:
</p></div>
1489 <div class=
"listingblock">
1490 <div class=
"content">
1491 <pre><code> [remote
"<name>"]
1493 pushurl =
<pushurl
>
1494 push =
<refspec
>
1495 fetch =
<refspec
></code></pre>
1497 <div class=
"paragraph"><p>The
<code><pushurl
></code> is used for pushes only. It is optional and defaults
1498 to
<code><URL
></code>.
</p></div>
1501 <h3 id=
"_named_file_in_code_git_dir_remotes_code">Named file in
<code>$GIT_DIR/remotes
</code></h3>
1502 <div class=
"paragraph"><p>You can choose to provide the name of a
1503 file in
<code>$GIT_DIR/remotes
</code>. The URL
1504 in this file will be used to access the repository. The refspec
1505 in this file will be used as default when you do not
1506 provide a refspec on the command line. This file should have the
1507 following format:
</p></div>
1508 <div class=
"listingblock">
1509 <div class=
"content">
1510 <pre><code> URL: one of the above URL format
1511 Push:
<refspec
>
1512 Pull:
<refspec
></code></pre>
1514 <div class=
"paragraph"><p><code>Push:
</code> lines are used by
<em>git push
</em> and
1515 <code>Pull:
</code> lines are used by
<em>git pull
</em> and
<em>git fetch
</em>.
1516 Multiple
<code>Push:
</code> and
<code>Pull:
</code> lines may
1517 be specified for additional branch mappings.
</p></div>
1520 <h3 id=
"_named_file_in_code_git_dir_branches_code">Named file in
<code>$GIT_DIR/branches
</code></h3>
1521 <div class=
"paragraph"><p>You can choose to provide the name of a
1522 file in
<code>$GIT_DIR/branches
</code>.
1523 The URL in this file will be used to access the repository.
1524 This file should have the following format:
</p></div>
1525 <div class=
"listingblock">
1526 <div class=
"content">
1527 <pre><code> <URL
>#
<head
></code></pre>
1529 <div class=
"paragraph"><p><code><URL
></code> is required;
<code>#
<head
></code> is optional.
</p></div>
1530 <div class=
"paragraph"><p>Depending on the operation, git will use one of the following
1531 refspecs, if you don
’t provide one on the command line.
1532 <code><branch
></code> is the name of this file in
<code>$GIT_DIR/branches
</code> and
1533 <code><head
></code> defaults to
<code>master
</code>.
</p></div>
1534 <div class=
"paragraph"><p>git fetch uses:
</p></div>
1535 <div class=
"listingblock">
1536 <div class=
"content">
1537 <pre><code> refs/heads/
<head
>:refs/heads/
<branch
></code></pre>
1539 <div class=
"paragraph"><p>git push uses:
</p></div>
1540 <div class=
"listingblock">
1541 <div class=
"content">
1542 <pre><code> HEAD:refs/heads/
<head
></code></pre>
1548 <h2 id=
"_output">OUTPUT
</h2>
1549 <div class=
"sectionbody">
1550 <div class=
"paragraph"><p>The output of
"git push" depends on the transport method used; this
1551 section describes the output when pushing over the Git protocol (either
1552 locally or via ssh).
</p></div>
1553 <div class=
"paragraph"><p>The status of the push is output in tabular form, with each line
1554 representing the status of a single ref. Each line is of the form:
</p></div>
1555 <div class=
"listingblock">
1556 <div class=
"content">
1557 <pre><code> <flag
> <summary
> <from
> -
> <to
> (
<reason
>)
</code></pre>
1559 <div class=
"paragraph"><p>If --porcelain is used, then each line of the output is of the form:
</p></div>
1560 <div class=
"listingblock">
1561 <div class=
"content">
1562 <pre><code> <flag
> \t
<from
>:
<to
> \t
<summary
> (
<reason
>)
</code></pre>
1564 <div class=
"paragraph"><p>The status of up-to-date refs is shown only if --porcelain or --verbose
1565 option is used.
</p></div>
1566 <div class=
"dlist"><dl>
1567 <dt class=
"hdlist1">
1572 A single character indicating the status of the ref:
1574 <div class=
"dlist"><dl>
1575 <dt class=
"hdlist1">
1580 for a successfully pushed fast-forward;
1583 <dt class=
"hdlist1">
1588 for a successful forced update;
1591 <dt class=
"hdlist1">
1596 for a successfully deleted ref;
1599 <dt class=
"hdlist1">
1604 for a successfully pushed new ref;
1607 <dt class=
"hdlist1">
1612 for a ref that was rejected or failed to push; and
1615 <dt class=
"hdlist1">
1620 for a ref that was up to date and did not need pushing.
1625 <dt class=
"hdlist1">
1630 For a successfully pushed ref, the summary shows the old and new
1631 values of the ref in a form suitable for using as an argument to
1632 <code>git log
</code> (this is
<code><old
>..
<new
></code> in most cases, and
1633 <code><old
>...
<new
></code> for forced non-fast-forward updates).
1635 <div class=
"paragraph"><p>For a failed update, more details are given:
</p></div>
1636 <div class=
"openblock">
1637 <div class=
"content">
1638 <div class=
"dlist"><dl>
1639 <dt class=
"hdlist1">
1644 Git did not try to send the ref at all, typically because it
1645 is not a fast-forward and you did not force the update.
1648 <dt class=
"hdlist1">
1653 The remote end refused the update. Usually caused by a hook
1654 on the remote side, or because the remote repository has one
1655 of the following safety options in effect:
1656 <code>receive.denyCurrentBranch
</code> (for pushes to the checked out
1657 branch),
<code>receive.denyNonFastForwards
</code> (for forced
1658 non-fast-forward updates),
<code>receive.denyDeletes
</code> or
1659 <code>receive.denyDeleteCurrent
</code>. See
<a href=
"git-config.html">git-config(
1)
</a>.
1662 <dt class=
"hdlist1">
1667 The remote end did not report the successful update of the ref,
1668 perhaps because of a temporary error on the remote side, a
1669 break in the network connection, or other transient error.
1675 <dt class=
"hdlist1">
1680 The name of the local ref being pushed, minus its
1681 <code>refs/
<type
>/
</code> prefix. In the case of deletion, the
1682 name of the local ref is omitted.
1685 <dt class=
"hdlist1">
1690 The name of the remote ref being updated, minus its
1691 <code>refs/
<type
>/
</code> prefix.
1694 <dt class=
"hdlist1">
1699 A human-readable explanation. In the case of successfully pushed
1700 refs, no explanation is needed. For a failed ref, the reason for
1701 failure is described.
1708 <h2 id=
"_note_about_fast_forwards">NOTE ABOUT FAST-FORWARDS
</h2>
1709 <div class=
"sectionbody">
1710 <div class=
"paragraph"><p>When an update changes a branch (or more in general, a ref) that used to
1711 point at commit A to point at another commit B, it is called a
1712 fast-forward update if and only if B is a descendant of A.
</p></div>
1713 <div class=
"paragraph"><p>In a fast-forward update from A to B, the set of commits that the original
1714 commit A built on top of is a subset of the commits the new commit B
1715 builds on top of. Hence, it does not lose any history.
</p></div>
1716 <div class=
"paragraph"><p>In contrast, a non-fast-forward update will lose history. For example,
1717 suppose you and somebody else started at the same commit X, and you built
1718 a history leading to commit B while the other person built a history
1719 leading to commit A. The history looks like this:
</p></div>
1720 <div class=
"listingblock">
1721 <div class=
"content">
1724 ---X---A
</code></pre>
1726 <div class=
"paragraph"><p>Further suppose that the other person already pushed changes leading to A
1727 back to the original repository from which you two obtained the original
1729 <div class=
"paragraph"><p>The push done by the other person updated the branch that used to point at
1730 commit X to point at commit A. It is a fast-forward.
</p></div>
1731 <div class=
"paragraph"><p>But if you try to push, you will attempt to update the branch (that
1732 now points at A) with commit B. This does
<em>not
</em> fast-forward. If you did
1733 so, the changes introduced by commit A will be lost, because everybody
1734 will now start building on top of B.
</p></div>
1735 <div class=
"paragraph"><p>The command by default does not allow an update that is not a fast-forward
1736 to prevent such loss of history.
</p></div>
1737 <div class=
"paragraph"><p>If you do not want to lose your work (history from X to B) or the work by
1738 the other person (history from X to A), you would need to first fetch the
1739 history from the repository, create a history that contains changes done
1740 by both parties, and push the result back.
</p></div>
1741 <div class=
"paragraph"><p>You can perform
"git pull", resolve potential conflicts, and
"git push"
1742 the result. A
"git pull" will create a merge commit C between commits A
1744 <div class=
"listingblock">
1745 <div class=
"content">
1748 ---X---A
</code></pre>
1750 <div class=
"paragraph"><p>Updating A with the resulting merge commit will fast-forward and your
1751 push will be accepted.
</p></div>
1752 <div class=
"paragraph"><p>Alternatively, you can rebase your change between X and B on top of A,
1753 with
"git pull --rebase", and push the result back. The rebase will
1754 create a new commit D that builds the change between X and B on top of
1756 <div class=
"listingblock">
1757 <div class=
"content">
1760 ---X---A
</code></pre>
1762 <div class=
"paragraph"><p>Again, updating A with this commit will fast-forward and your push will be
1764 <div class=
"paragraph"><p>There is another common situation where you may encounter non-fast-forward
1765 rejection when you try to push, and it is possible even when you are
1766 pushing into a repository nobody else pushes into. After you push commit
1767 A yourself (in the first picture in this section), replace it with
"git
1768 commit --amend" to produce commit B, and you try to push it out, because
1769 forgot that you have pushed A out already. In such a case, and only if
1770 you are certain that nobody in the meantime fetched your earlier commit A
1771 (and started building on top of it), you can run
"git push --force" to
1772 overwrite it. In other words,
"git push --force" is a method reserved for
1773 a case where you do mean to lose history.
</p></div>
1777 <h2 id=
"_examples">EXAMPLES
</h2>
1778 <div class=
"sectionbody">
1779 <div class=
"dlist"><dl>
1780 <dt class=
"hdlist1">
1781 <code>git push
</code>
1785 Works like
<code>git push
<remote
></code>, where
<remote
> is the
1786 current branch
’s remote (or
<code>origin
</code>, if no remote is
1787 configured for the current branch).
1790 <dt class=
"hdlist1">
1791 <code>git push origin
</code>
1795 Without additional configuration, pushes the current branch to
1796 the configured upstream (
<code>branch.
<name
>.merge
</code> configuration
1797 variable) if it has the same name as the current branch, and
1798 errors out without pushing otherwise.
1800 <div class=
"paragraph"><p>The default behavior of this command when no
<refspec
> is given can be
1801 configured by setting the
<code>push
</code> option of the remote, or the
<code>push.default
</code>
1802 configuration variable.
</p></div>
1803 <div class=
"paragraph"><p>For example, to default to pushing only the current branch to
<code>origin
</code>
1804 use
<code>git config remote.origin.push HEAD
</code>. Any valid
<refspec
> (like
1805 the ones in the examples below) can be configured as the default for
1806 <code>git push origin
</code>.
</p></div>
1808 <dt class=
"hdlist1">
1809 <code>git push origin :
</code>
1813 Push
"matching" branches to
<code>origin
</code>. See
1814 <refspec
> in the
<a href=
"#OPTIONS">OPTIONS
</a> section above for a
1815 description of
"matching" branches.
1818 <dt class=
"hdlist1">
1819 <code>git push origin master
</code>
1823 Find a ref that matches
<code>master
</code> in the source repository
1824 (most likely, it would find
<code>refs/heads/master
</code>), and update
1825 the same ref (e.g.
<code>refs/heads/master
</code>) in
<code>origin
</code> repository
1826 with it. If
<code>master
</code> did not exist remotely, it would be
1830 <dt class=
"hdlist1">
1831 <code>git push origin HEAD
</code>
1835 A handy way to push the current branch to the same name on the
1839 <dt class=
"hdlist1">
1840 <code>git push mothership master:satellite/master dev:satellite/dev
</code>
1844 Use the source ref that matches
<code>master
</code> (e.g.
<code>refs/heads/master
</code>)
1845 to update the ref that matches
<code>satellite/master
</code> (most probably
1846 <code>refs/remotes/satellite/master
</code>) in the
<code>mothership
</code> repository;
1847 do the same for
<code>dev
</code> and
<code>satellite/dev
</code>.
1849 <div class=
"paragraph"><p>See the section describing
<code><refspec
>...
</code> above for a discussion of
1850 the matching semantics.
</p></div>
1851 <div class=
"paragraph"><p>This is to emulate
<code>git fetch
</code> run on the
<code>mothership
</code> using
<code>git
1852 push
</code> that is run in the opposite direction in order to integrate
1853 the work done on
<code>satellite
</code>, and is often necessary when you can
1854 only make connection in one way (i.e. satellite can ssh into
1855 mothership but mothership cannot initiate connection to satellite
1856 because the latter is behind a firewall or does not run sshd).
</p></div>
1857 <div class=
"paragraph"><p>After running this
<code>git push
</code> on the
<code>satellite
</code> machine, you would
1858 ssh into the
<code>mothership
</code> and run
<code>git merge
</code> there to complete the
1859 emulation of
<code>git pull
</code> that were run on
<code>mothership
</code> to pull changes
1860 made on
<code>satellite
</code>.
</p></div>
1862 <dt class=
"hdlist1">
1863 <code>git push origin HEAD:master
</code>
1867 Push the current branch to the remote ref matching
<code>master
</code> in the
1868 <code>origin
</code> repository. This form is convenient to push the current
1869 branch without thinking about its local name.
1872 <dt class=
"hdlist1">
1873 <code>git push origin master:refs/heads/experimental
</code>
1877 Create the branch
<code>experimental
</code> in the
<code>origin
</code> repository
1878 by copying the current
<code>master
</code> branch. This form is only
1879 needed to create a new branch or tag in the remote repository when
1880 the local name and the remote name are different; otherwise,
1881 the ref name on its own will work.
1884 <dt class=
"hdlist1">
1885 <code>git push origin :experimental
</code>
1889 Find a ref that matches
<code>experimental
</code> in the
<code>origin
</code> repository
1890 (e.g.
<code>refs/heads/experimental
</code>), and delete it.
1893 <dt class=
"hdlist1">
1894 <code>git push origin +dev:master
</code>
1898 Update the origin repository
’s master branch with the dev branch,
1899 allowing non-fast-forward updates.
<strong>This can leave unreferenced
1900 commits dangling in the origin repository.
</strong> Consider the
1901 following situation, where a fast-forward is not possible:
1903 <div class=
"listingblock">
1904 <div class=
"content">
1905 <pre><code> o---o---o---A---B origin/master
1907 X---Y---Z dev
</code></pre>
1909 <div class=
"paragraph"><p>The above command would change the origin repository to
</p></div>
1910 <div class=
"listingblock">
1911 <div class=
"content">
1912 <pre><code> A---B (unnamed branch)
1914 o---o---o---X---Y---Z master
</code></pre>
1916 <div class=
"paragraph"><p>Commits A and B would no longer belong to a branch with a symbolic name,
1917 and so would be unreachable. As such, these commits would be removed by
1918 a
<code>git gc
</code> command on the origin repository.
</p></div>
1924 <h2 id=
"_security">SECURITY
</h2>
1925 <div class=
"sectionbody">
1926 <div class=
"paragraph"><p>The fetch and push protocols are not designed to prevent one side from
1927 stealing data from the other repository that was not intended to be
1928 shared. If you have private data that you need to protect from a malicious
1929 peer, your best option is to store it in another repository. This applies
1930 to both clients and servers. In particular, namespaces on a server are not
1931 effective for read access control; you should only grant read access to a
1932 namespace to clients that you would trust with read access to the entire
1933 repository.
</p></div>
1934 <div class=
"paragraph"><p>The known attack vectors are as follows:
</p></div>
1935 <div class=
"olist arabic"><ol class=
"arabic">
1938 The victim sends
"have" lines advertising the IDs of objects it has that
1939 are not explicitly intended to be shared but can be used to optimize the
1940 transfer if the peer also has them. The attacker chooses an object ID X
1941 to steal and sends a ref to X, but isn
’t required to send the content of
1942 X because the victim already has it. Now the victim believes that the
1943 attacker has X, and it sends the content of X back to the attacker
1944 later. (This attack is most straightforward for a client to perform on a
1945 server, by creating a ref to X in the namespace the client has access
1946 to and then fetching it. The most likely way for a server to perform it
1947 on a client is to
"merge" X into a public branch and hope that the user
1948 does additional work on this branch and pushes it back to the server
1949 without noticing the merge.)
1954 As in #
1, the attacker chooses an object ID X to steal. The victim sends
1955 an object Y that the attacker already has, and the attacker falsely
1956 claims to have X and not Y, so the victim sends Y as a delta against X.
1957 The delta reveals regions of X that are similar to Y to the attacker.
1964 <h2 id=
"_configuration">CONFIGURATION
</h2>
1965 <div class=
"sectionbody">
1966 <div class=
"paragraph"><p>Everything below this line in this section is selectively included
1967 from the
<a href=
"git-config.html">git-config(
1)
</a> documentation. The content is the same
1968 as what
’s found there:
</p></div>
1969 <div class=
"dlist"><dl>
1970 <dt class=
"hdlist1">
1971 push.autoSetupRemote
1975 If set to
"true" assume
<code>--set-upstream
</code> on default push when no
1976 upstream tracking exists for the current branch; this option
1977 takes effect with push.default options
<em>simple
</em>,
<em>upstream
</em>,
1978 and
<em>current
</em>. It is useful if by default you want new branches
1979 to be pushed to the default remote (like the behavior of
1980 <em>push.default=current
</em>) and you also want the upstream tracking
1981 to be set. Workflows most likely to benefit from this option are
1982 <em>simple
</em> central workflows where all branches are expected to
1983 have the same name on the remote.
1986 <dt class=
"hdlist1">
1991 Defines the action
<code>git push
</code> should take if no refspec is
1992 given (whether from the command-line, config, or elsewhere).
1993 Different values are well-suited for
1994 specific workflows; for instance, in a purely central workflow
1995 (i.e. the fetch source is equal to the push destination),
1996 <code>upstream
</code> is probably what you want. Possible values are:
1998 <div class=
"openblock">
1999 <div class=
"content">
2000 <div class=
"ulist"><ul>
2003 <code>nothing
</code> - do not push anything (error out) unless a refspec is
2004 given. This is primarily meant for people who want to
2005 avoid mistakes by always being explicit.
2010 <code>current
</code> - push the current branch to update a branch with the same
2011 name on the receiving end. Works in both central and non-central
2017 <code>upstream
</code> - push the current branch back to the branch whose
2018 changes are usually integrated into the current branch (which is
2019 called
<code>@{upstream}
</code>). This mode only makes sense if you are
2020 pushing to the same repository you would normally pull from
2021 (i.e. central workflow).
2026 <code>tracking
</code> - This is a deprecated synonym for
<code>upstream
</code>.
2031 <code>simple
</code> - pushes the current branch with the same name on the remote.
2033 <div class=
"paragraph"><p>If you are working on a centralized workflow (pushing to the same repository you
2034 pull from, which is typically
<code>origin
</code>), then you need to configure an upstream
2035 branch with the same name.
</p></div>
2036 <div class=
"paragraph"><p>This mode is the default since Git
2.0, and is the safest option suited for
2037 beginners.
</p></div>
2041 <code>matching
</code> - push all branches having the same name on both ends.
2042 This makes the repository you are pushing to remember the set of
2043 branches that will be pushed out (e.g. if you always push
<em>maint
</em>
2044 and
<em>master
</em> there and no other branches, the repository you push
2045 to will have these two branches, and your local
<em>maint
</em> and
2046 <em>master
</em> will be pushed there).
2048 <div class=
"paragraph"><p>To use this mode effectively, you have to make sure
<em>all
</em> the
2049 branches you would push out are ready to be pushed out before
2050 running
<em>git push
</em>, as the whole point of this mode is to allow you
2051 to push all of the branches in one go. If you usually finish work
2052 on only one branch and push out the result, while other branches are
2053 unfinished, this mode is not for you. Also this mode is not
2054 suitable for pushing into a shared central repository, as other
2055 people may add new branches there, or update the tip of existing
2056 branches outside your control.
</p></div>
2057 <div class=
"paragraph"><p>This used to be the default, but not since Git
2.0 (
<code>simple
</code> is the
2058 new default).
</p></div>
2063 <dt class=
"hdlist1">
2068 If set to true enable
<code>--follow-tags
</code> option by default. You
2069 may override this configuration at time of push by specifying
2070 <code>--no-follow-tags
</code>.
2073 <dt class=
"hdlist1">
2078 May be set to a boolean value, or the string
<em>if-asked
</em>. A true
2079 value causes all pushes to be GPG signed, as if
<code>--signed
</code> is
2080 passed to
<a href=
"git-push.html">git-push(
1)
</a>. The string
<em>if-asked
</em> causes
2081 pushes to be signed if the server supports it, as if
2082 <code>--signed=if-asked
</code> is passed to
<em>git push
</em>. A false value may
2083 override a value from a lower-priority config file. An explicit
2084 command-line flag always overrides this config option.
2087 <dt class=
"hdlist1">
2092 When no
<code>--push-option=
<option
></code> argument is given from the
2093 command line,
<code>git push
</code> behaves as if each
<value
> of
2094 this variable is given as
<code>--push-option=
<value
></code>.
2096 <div class=
"paragraph"><p>This is a multi-valued variable, and an empty value can be used in a
2097 higher priority configuration file (e.g.
<code>.git/config
</code> in a
2098 repository) to clear the values inherited from a lower priority
2099 configuration files (e.g.
<code>$HOME/.gitconfig
</code>).
</p></div>
2100 <div class=
"listingblock">
2101 <div class=
"content">
2115 This will result in only b (a and c are cleared).
</code></pre>
2118 <dt class=
"hdlist1">
2119 push.recurseSubmodules
2123 Make sure all submodule commits used by the revisions to be pushed
2124 are available on a remote-tracking branch. If the value is
<em>check
</em>
2125 then Git will verify that all submodule commits that changed in the
2126 revisions to be pushed are available on at least one remote of the
2127 submodule. If any commits are missing, the push will be aborted and
2128 exit with non-zero status. If the value is
<em>on-demand
</em> then all
2129 submodules that changed in the revisions to be pushed will be
2130 pushed. If on-demand was not able to push all necessary revisions
2131 it will also be aborted and exit with non-zero status. If the value
2132 is
<em>no
</em> then default behavior of ignoring submodules when pushing
2133 is retained. You may override this configuration at time of push by
2134 specifying
<em>--recurse-submodules=check|on-demand|no
</em>.
2135 If not set,
<em>no
</em> is used by default, unless
<em>submodule.recurse
</em> is
2136 set (in which case a
<em>true
</em> value means
<em>on-demand
</em>).
2139 <dt class=
"hdlist1">
2140 push.useForceIfIncludes
2144 If set to
"true", it is equivalent to specifying
2145 <code>--force-if-includes
</code> as an option to
<a href=
"git-push.html">git-push(
1)
</a>
2146 in the command line. Adding
<code>--no-force-if-includes
</code> at the
2147 time of push overrides this configuration setting.
2150 <dt class=
"hdlist1">
2155 If set to
"true", attempt to reduce the size of the packfile
2156 sent by rounds of negotiation in which the client and the
2157 server attempt to find commits in common. If
"false", Git will
2158 rely solely on the server
’s ref advertisement to find commits
2162 <dt class=
"hdlist1">
2167 If set to
"false", disable use of bitmaps for
"git push" even if
2168 <code>pack.useBitmaps
</code> is
"true", without preventing other git operations
2169 from using bitmaps. Default is true.
2176 <h2 id=
"_git">GIT
</h2>
2177 <div class=
"sectionbody">
2178 <div class=
"paragraph"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
2182 <div id=
"footnotes"><hr /></div>
2184 <div id=
"footer-text">
2186 2022-
09-
14 13:
23:
11 PDT