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.4.5" />
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.5em;
129 div
.content
{ /* Block element content. */
133 /* Block element titles. */
134 div
.title
, caption
.title
{
136 font-family: sans-serif
;
140 margin-bottom: 0.5em;
146 td div
.title:first-child
{
149 div
.content div
.title:first-child
{
152 div
.content
+ div
.title
{
156 div
.sidebarblock
> div
.content
{
158 border: 1px solid silver
;
162 div
.listingblock
> div
.content
{
163 border: 1px solid silver
;
172 div
.quoteblock
> div
.attribution
{
181 div
.verseblock
> div
.content
{
184 div
.verseblock
> div
.attribution
{
188 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
189 div
.verseblock
+ div
.attribution
{
193 div
.admonitionblock
.icon
{
197 text-decoration: underline
;
199 padding-right: 0.5em;
201 div
.admonitionblock td
.content
{
203 border-left: 2px solid silver
;
206 div
.exampleblock
> div
.content
{
207 border-left: 2px solid silver
;
211 div
.imageblock div
.content
{ padding-left: 0; }
212 span
.image img
{ border-style: none
; }
213 a
.image:visited
{ color: white
; }
217 margin-bottom: 0.8em;
230 list-style-position: outside
;
233 list-style-type: decimal
;
236 list-style-type: lower-alpha
;
239 list-style-type: upper-alpha
;
242 list-style-type: lower-roman
;
245 list-style-type: upper-roman
;
248 div
.compact ul
, div
.compact ol
,
249 div
.compact p
, div
.compact p
,
250 div
.compact div
, div
.compact div
{
252 margin-bottom: 0.1em;
255 div
.tableblock
> table
{
256 border: 3px solid
#527bbd;
259 font-family: sans-serif
;
271 /* Because the table frame attribute is overriden by CSS in most browsers. */
272 div
.tableblock
> table
[frame
="void"] {
275 div
.tableblock
> table
[frame
="hsides"] {
276 border-left-style: none
;
277 border-right-style: none
;
279 div
.tableblock
> table
[frame
="vsides"] {
280 border-top-style: none
;
281 border-bottom-style: none
;
287 margin-bottom: 0.8em;
290 padding-bottom: 15px;
292 dt
.hdlist1
.strong
, td
.hdlist1
.strong
{
298 padding-right: 0.8em;
304 div
.hdlist
.compact tr
{
314 div#footer-badges
{ display: none
; }
319 font-family: sans-serif
;
323 margin-bottom: 0.1em;
326 div
.toclevel1
, div
.toclevel2
, div
.toclevel3
, div
.toclevel4
{
342 /* Overrides for manpage documents */
345 padding-bottom: 0.5em;
346 border-top: 2px solid silver
;
347 border-bottom: 2px solid silver
;
357 div#toc
{ display: none
; }
360 /* Workarounds for IE6's broken and incomplete CSS2. */
362 div
.sidebar-content
{
364 border: 1px solid silver
;
367 div
.sidebar-title
, div
.image-title
{
369 font-family: sans-serif
;
372 margin-bottom: 0.5em;
375 div
.listingblock div
.content
{
376 border: 1px solid silver
;
381 div
.quoteblock-attribution
{
386 div
.verseblock-content
{
389 div
.verseblock-attribution
{
394 div
.exampleblock-content
{
395 border-left: 2px solid silver
;
399 /* IE6 sets dynamically generated links as visited. */
400 div#toc
a:visited
{ color: blue
; }
406 git-push(
1) Manual Page
409 <div class=
"sectionbody">
411 Update remote refs along with associated objects
415 <h2 id=
"_synopsis">SYNOPSIS
</h2>
416 <div class=
"sectionbody">
417 <div class=
"verseblock">
418 <div class=
"verseblock-content"><em>git push
</em> [--all | --mirror | --tags] [-n | --dry-run] [--receive-pack=
<git-receive-pack
>]
419 [--repo=
<repository
>] [-f | --force] [-v | --verbose] [-u | --set-upstream]
420 [
<repository
> [
<refspec
>…]]
</div>
421 <div class=
"verseblock-attribution">
424 <h2 id=
"_description">DESCRIPTION
</h2>
425 <div class=
"sectionbody">
426 <div class=
"paragraph"><p>Updates remote refs using local refs, while sending objects
427 necessary to complete the given refs.
</p></div>
428 <div class=
"paragraph"><p>You can make interesting things happen to a repository
429 every time you push into it, by setting up
<em>hooks
</em> there. See
430 documentation for
<a href=
"git-receive-pack.html">git-receive-pack(
1)
</a>.
</p></div>
432 <h2 id=
"_options_a_id_options_a">OPTIONS
<a id=
"OPTIONS"></a></h2>
433 <div class=
"sectionbody">
434 <div class=
"dlist"><dl>
440 The
"remote" repository that is destination of a push
441 operation. This parameter can be either a URL
442 (see the section
<a href=
"#URLS">GIT URLS
</a> below) or the name
443 of a remote (see the section
<a href=
"#REMOTES">REMOTES
</a> below).
447 <refspec
>…
451 The format of a
<refspec
> parameter is an optional plus
452 <tt>+</tt>, followed by the source ref
<src
>, followed
453 by a colon
<tt>:
</tt>, followed by the destination ref
<dst
>.
454 It is used to specify with what
<src
> object the
<dst
> ref
455 in the remote repository is to be updated.
457 <div class=
"paragraph"><p>The
<src
> is often the name of the branch you would want to push, but
458 it can be any arbitrary
"SHA-1 expression", such as
<tt>master~
4</tt> or
459 <tt>HEAD
</tt> (see
<a href=
"gitrevisions.html">gitrevisions(
7)
</a>).
</p></div>
460 <div class=
"paragraph"><p>The
<dst
> tells which ref on the remote side is updated with this
461 push. Arbitrary expressions cannot be used here, an actual ref must
462 be named. If
<tt>:
</tt><dst
> is omitted, the same ref as
<src
> will be
464 <div class=
"paragraph"><p>The object referenced by
<src
> is used to update the
<dst
> reference
465 on the remote side, but by default this is only allowed if the
466 update can fast-forward
<dst
>. By having the optional leading
<tt>+</tt>,
467 you can tell git to update the
<dst
> ref even when the update is not a
468 fast-forward. This does
<strong>not
</strong> attempt to merge
<src
> into
<dst
>. See
469 EXAMPLES below for details.
</p></div>
470 <div class=
"paragraph"><p><tt>tag
<tag
></tt> means the same as
<tt>refs/tags/
<tag
>:refs/tags/
<tag
></tt>.
</p></div>
471 <div class=
"paragraph"><p>Pushing an empty
<src
> allows you to delete the
<dst
> ref from
472 the remote repository.
</p></div>
473 <div class=
"paragraph"><p>The special refspec
<tt>:
</tt> (or
<tt>+:
</tt> to allow non-fast-forward updates)
474 directs git to push
"matching" branches: for every branch that exists on
475 the local side, the remote side is updated if a branch of the same name
476 already exists on the remote side. This is the default operation mode
477 if no explicit refspec is found (that is neither on the command line
478 nor in any Push line of the corresponding remotes file---see below).
</p></div>
485 Instead of naming each ref to push, specifies that all
486 refs under
<tt>refs/heads/
</tt> be pushed.
494 Instead of naming each ref to push, specifies that all
495 refs under
<tt>refs/
</tt> (which includes but is not
496 limited to
<tt>refs/heads/
</tt>,
<tt>refs/remotes/
</tt>, and
<tt>refs/tags/
</tt>)
497 be mirrored to the remote repository. Newly created local
498 refs will be pushed to the remote end, locally updated refs
499 will be force updated on the remote end, and deleted refs
500 will be removed from the remote end. This is the default
501 if the configuration option
<tt>remote.
<remote
>.mirror
</tt> is
513 Do everything except actually send the updates.
521 Produce machine-readable output. The output status line for each ref
522 will be tab-separated and sent to stdout instead of stderr. The full
523 symbolic names of the refs will be given.
531 All listed refs are deleted from the remote repository. This is
532 the same as prefixing all refs with a colon.
540 All refs under
<tt>refs/tags
</tt> are pushed, in
541 addition to refspecs explicitly listed on the command
546 --receive-pack=
<git-receive-pack
>
549 --exec=
<git-receive-pack
>
553 Path to the
<em>git-receive-pack
</em> program on the remote
554 end. Sometimes useful when pushing to a remote
555 repository over ssh, and you do not have the program in
556 a directory on the default $PATH.
567 Usually, the command refuses to update a remote ref that is
568 not an ancestor of the local ref used to overwrite it.
569 This flag disables the check. This can cause the
570 remote repository to lose commits; use it with care.
574 --repo=
<repository
>
578 This option is only relevant if no
<repository
> argument is
579 passed in the invocation. In this case,
<em>git push
</em> derives the
580 remote name from the current branch: If it tracks a remote
581 branch, then that remote repository is pushed to. Otherwise,
582 the name
"origin" is used. For this latter case, this option
583 can be used to override the name
"origin". In other words,
584 the difference between these two commands
586 <div class=
"listingblock">
587 <div class=
"content">
588 <pre><tt>git push public #
1
589 git push --repo=public #
2</tt></pre>
591 <div class=
"paragraph"><p>is that #
1 always pushes to
"public" whereas #
2 pushes to
"public"
592 only if the current branch does not track a remote branch. This is
593 useful if you write an alias or script around
<em>git push
</em>.
</p></div>
603 For every branch that is up to date or successfully pushed, add
604 upstream (tracking) reference, used by argument-less
605 <a href=
"git-pull.html">git-pull(
1)
</a> and other commands. For more information,
606 see
<em>branch.
<name
>.merge
</em> in
<a href=
"git-config.html">git-config(
1)
</a>.
617 These options are passed to
<a href=
"git-send-pack.html">git-send-pack(
1)
</a>. A thin transfer
618 significantly reduces the amount of sent data when the sender and
619 receiver share many of the same objects in common. The default is
631 Suppress all output, including the listing of updated refs,
632 unless an error occurs. Progress is not reported to the standard
652 Progress status is reported on the standard error stream
653 by default when it is attached to a terminal, unless -q
654 is specified. This flag forces progress status even if the
655 standard error stream is not directed to a terminal.
660 <h2 id=
"_git_urls_a_id_urls_a">GIT URLS
<a id=
"URLS"></a></h2>
661 <div class=
"sectionbody">
662 <div class=
"paragraph"><p>In general, URLs contain information about the transport protocol, the
663 address of the remote server, and the path to the repository.
664 Depending on the transport protocol, some of this information may be
666 <div class=
"paragraph"><p>Git natively supports ssh, git, http, https, ftp, ftps, and rsync
667 protocols. The following syntaxes may be used with them:
</p></div>
668 <div class=
"ulist"><ul>
671 ssh://
[user@
]host.xz
[:port
]/path/to/repo.git/
676 git://host.xz
[:port
]/path/to/repo.git/
681 http
[s
]://host.xz
[:port
]/path/to/repo.git/
686 ftp
[s
]://host.xz
[:port
]/path/to/repo.git/
691 rsync://host.xz/path/to/repo.git/
695 <div class=
"paragraph"><p>An alternative scp-like syntax may also be used with the ssh protocol:
</p></div>
696 <div class=
"ulist"><ul>
699 [user@
]host.xz:path/to/repo.git/
703 <div class=
"paragraph"><p>The ssh and git protocols additionally support ~username expansion:
</p></div>
704 <div class=
"ulist"><ul>
707 ssh://
[user@
]host.xz
[:port
]/~
[user
]/path/to/repo.git/
712 git://host.xz
[:port
]/~
[user
]/path/to/repo.git/
717 [user@
]host.xz:/~
[user
]/path/to/repo.git/
721 <div class=
"paragraph"><p>For local repositories, also supported by git natively, the following
722 syntaxes may be used:
</p></div>
723 <div class=
"ulist"><ul>
731 <a href=
"file:///path/to/repo.git/">file:///path/to/repo.git/
</a>
735 <div class=
"paragraph"><p>These two syntaxes are mostly equivalent, except when cloning, when
736 the former implies --local option. See
<a href=
"git-clone.html">git-clone(
1)
</a> for
738 <div class=
"paragraph"><p>When git doesn
’t know how to handle a certain transport protocol, it
739 attempts to use the
<em>remote-
<transport
></em> remote helper, if one
740 exists. To explicitly request a remote helper, the following syntax
741 may be used:
</p></div>
742 <div class=
"ulist"><ul>
745 <transport
>::
<address
>
749 <div class=
"paragraph"><p>where
<address
> may be a path, a server and path, or an arbitrary
750 URL-like string recognized by the specific remote helper being
751 invoked. See
<a href=
"git-remote-helpers.html">git-remote-helpers(
1)
</a> for details.
</p></div>
752 <div class=
"paragraph"><p>If there are a large number of similarly-named remote repositories and
753 you want to use a different format for them (such that the URLs you
754 use will be rewritten into URLs that work), you can create a
755 configuration section of the form:
</p></div>
756 <div class=
"listingblock">
757 <div class=
"content">
758 <pre><tt> [url
"<actual url base>"]
759 insteadOf =
<other url base
></tt></pre>
761 <div class=
"paragraph"><p>For example, with this:
</p></div>
762 <div class=
"listingblock">
763 <div class=
"content">
764 <pre><tt> [url
"git://git.host.xz/"]
765 insteadOf = host.xz:/path/to/
766 insteadOf = work:
</tt></pre>
768 <div class=
"paragraph"><p>a URL like
"work:repo.git" or like
"host.xz:/path/to/repo.git" will be
769 rewritten in any context that takes a URL to be
"git://git.host.xz/repo.git".
</p></div>
770 <div class=
"paragraph"><p>If you want to rewrite URLs for push only, you can create a
771 configuration section of the form:
</p></div>
772 <div class=
"listingblock">
773 <div class=
"content">
774 <pre><tt> [url
"<actual url base>"]
775 pushInsteadOf =
<other url base
></tt></pre>
777 <div class=
"paragraph"><p>For example, with this:
</p></div>
778 <div class=
"listingblock">
779 <div class=
"content">
780 <pre><tt> [url
"ssh://example.org/"]
781 pushInsteadOf = git://example.org/
</tt></pre>
783 <div class=
"paragraph"><p>a URL like
"git://example.org/path/to/repo.git" will be rewritten to
784 "ssh://example.org/path/to/repo.git" for pushes, but pulls will still
785 use the original URL.
</p></div>
787 <h2 id=
"_remotes_a_id_remotes_a">REMOTES
<a id=
"REMOTES"></a></h2>
788 <div class=
"sectionbody">
789 <div class=
"paragraph"><p>The name of one of the following can be used instead
790 of a URL as
<tt><repository
></tt> argument:
</p></div>
791 <div class=
"ulist"><ul>
794 a remote in the git configuration file:
<tt>$GIT_DIR/config
</tt>,
799 a file in the
<tt>$GIT_DIR/remotes
</tt> directory, or
804 a file in the
<tt>$GIT_DIR/branches
</tt> directory.
808 <div class=
"paragraph"><p>All of these also allow you to omit the refspec from the command line
809 because they each contain a refspec which git will use by default.
</p></div>
810 <h3 id=
"_named_remote_in_configuration_file">Named remote in configuration file
</h3><div style=
"clear:left"></div>
811 <div class=
"paragraph"><p>You can choose to provide the name of a remote which you had previously
812 configured using
<a href=
"git-remote.html">git-remote(
1)
</a>,
<a href=
"git-config.html">git-config(
1)
</a>
813 or even by a manual edit to the
<tt>$GIT_DIR/config
</tt> file. The URL of
814 this remote will be used to access the repository. The refspec
815 of this remote will be used by default when you do
816 not provide a refspec on the command line. The entry in the
817 config file would appear like this:
</p></div>
818 <div class=
"listingblock">
819 <div class=
"content">
820 <pre><tt> [remote
"<name>"]
822 pushurl =
<pushurl
>
823 push =
<refspec
>
824 fetch =
<refspec
></tt></pre>
826 <div class=
"paragraph"><p>The
<tt><pushurl
></tt> is used for pushes only. It is optional and defaults
827 to
<tt><url
></tt>.
</p></div>
828 <h3 id=
"_named_file_in_tt_git_dir_remotes_tt">Named file in
<tt>$GIT_DIR/remotes
</tt></h3><div style=
"clear:left"></div>
829 <div class=
"paragraph"><p>You can choose to provide the name of a
830 file in
<tt>$GIT_DIR/remotes
</tt>. The URL
831 in this file will be used to access the repository. The refspec
832 in this file will be used as default when you do not
833 provide a refspec on the command line. This file should have the
834 following format:
</p></div>
835 <div class=
"listingblock">
836 <div class=
"content">
837 <pre><tt> URL: one of the above URL format
838 Push:
<refspec
>
839 Pull:
<refspec
></tt></pre>
841 <div class=
"paragraph"><p><tt>Push:
</tt> lines are used by
<em>git push
</em> and
842 <tt>Pull:
</tt> lines are used by
<em>git pull
</em> and
<em>git fetch
</em>.
843 Multiple
<tt>Push:
</tt> and
<tt>Pull:
</tt> lines may
844 be specified for additional branch mappings.
</p></div>
845 <h3 id=
"_named_file_in_tt_git_dir_branches_tt">Named file in
<tt>$GIT_DIR/branches
</tt></h3><div style=
"clear:left"></div>
846 <div class=
"paragraph"><p>You can choose to provide the name of a
847 file in
<tt>$GIT_DIR/branches
</tt>.
848 The URL in this file will be used to access the repository.
849 This file should have the following format:
</p></div>
850 <div class=
"listingblock">
851 <div class=
"content">
852 <pre><tt> <url
>#
<head
></tt></pre>
854 <div class=
"paragraph"><p><tt><url
></tt> is required;
<tt>#
<head
></tt> is optional.
</p></div>
855 <div class=
"paragraph"><p>Depending on the operation, git will use one of the following
856 refspecs, if you don
’t provide one on the command line.
857 <tt><branch
></tt> is the name of this file in
<tt>$GIT_DIR/branches
</tt> and
858 <tt><head
></tt> defaults to
<tt>master
</tt>.
</p></div>
859 <div class=
"paragraph"><p>git fetch uses:
</p></div>
860 <div class=
"listingblock">
861 <div class=
"content">
862 <pre><tt> refs/heads/
<head
>:refs/heads/
<branch
></tt></pre>
864 <div class=
"paragraph"><p>git push uses:
</p></div>
865 <div class=
"listingblock">
866 <div class=
"content">
867 <pre><tt> HEAD:refs/heads/
<head
></tt></pre>
870 <h2 id=
"_output">OUTPUT
</h2>
871 <div class=
"sectionbody">
872 <div class=
"paragraph"><p>The output of
"git push" depends on the transport method used; this
873 section describes the output when pushing over the git protocol (either
874 locally or via ssh).
</p></div>
875 <div class=
"paragraph"><p>The status of the push is output in tabular form, with each line
876 representing the status of a single ref. Each line is of the form:
</p></div>
877 <div class=
"listingblock">
878 <div class=
"content">
879 <pre><tt> <flag
> <summary
> <from
> -
> <to
> (
<reason
>)
</tt></pre>
881 <div class=
"paragraph"><p>If --porcelain is used, then each line of the output is of the form:
</p></div>
882 <div class=
"listingblock">
883 <div class=
"content">
884 <pre><tt> <flag
> \t
<from
>:
<to
> \t
<summary
> (
<reason
>)
</tt></pre>
886 <div class=
"paragraph"><p>The status of up-to-date refs is shown only if --porcelain or --verbose
887 option is used.
</p></div>
888 <div class=
"dlist"><dl>
894 A single character indicating the status of the ref:
896 <div class=
"dlist"><dl>
902 for a successfully pushed fast-forward;
910 for a successful forced update;
918 for a successfully deleted ref;
926 for a successfully pushed new ref;
934 for a ref that was rejected or failed to push; and
942 for a ref that was up to date and did not need pushing.
952 For a successfully pushed ref, the summary shows the old and new
953 values of the ref in a form suitable for using as an argument to
954 <tt>git log
</tt> (this is
<tt><old
>..
<new
></tt> in most cases, and
955 <tt><old
>...
<new
></tt> for forced non-fast-forward updates).
957 <div class=
"paragraph"><p>For a failed update, more details are given:
</p></div>
958 <div class=
"dlist"><dl>
964 Git did not try to send the ref at all, typically because it
965 is not a fast-forward and you did not force the update.
973 The remote end refused the update. Usually caused by a hook
974 on the remote side, or because the remote repository has one
975 of the following safety options in effect:
976 <tt>receive.denyCurrentBranch
</tt> (for pushes to the checked out
977 branch),
<tt>receive.denyNonFastForwards
</tt> (for forced
978 non-fast-forward updates),
<tt>receive.denyDeletes
</tt> or
979 <tt>receive.denyDeleteCurrent
</tt>. See
<a href=
"git-config.html">git-config(
1)
</a>.
987 The remote end did not report the successful update of the ref,
988 perhaps because of a temporary error on the remote side, a
989 break in the network connection, or other transient error.
999 The name of the local ref being pushed, minus its
1000 <tt>refs/
<type
>/
</tt> prefix. In the case of deletion, the
1001 name of the local ref is omitted.
1004 <dt class=
"hdlist1">
1009 The name of the remote ref being updated, minus its
1010 <tt>refs/
<type
>/
</tt> prefix.
1013 <dt class=
"hdlist1">
1018 A human-readable explanation. In the case of successfully pushed
1019 refs, no explanation is needed. For a failed ref, the reason for
1020 failure is described.
1025 <h2 id=
"_note_about_fast_forwards">Note about fast-forwards
</h2>
1026 <div class=
"sectionbody">
1027 <div class=
"paragraph"><p>When an update changes a branch (or more in general, a ref) that used to
1028 point at commit A to point at another commit B, it is called a
1029 fast-forward update if and only if B is a descendant of A.
</p></div>
1030 <div class=
"paragraph"><p>In a fast-forward update from A to B, the set of commits that the original
1031 commit A built on top of is a subset of the commits the new commit B
1032 builds on top of. Hence, it does not lose any history.
</p></div>
1033 <div class=
"paragraph"><p>In contrast, a non-fast-forward update will lose history. For example,
1034 suppose you and somebody else started at the same commit X, and you built
1035 a history leading to commit B while the other person built a history
1036 leading to commit A. The history looks like this:
</p></div>
1037 <div class=
"listingblock">
1038 <div class=
"content">
1043 <div class=
"paragraph"><p>Further suppose that the other person already pushed changes leading to A
1044 back to the original repository you two obtained the original commit X.
</p></div>
1045 <div class=
"paragraph"><p>The push done by the other person updated the branch that used to point at
1046 commit X to point at commit A. It is a fast-forward.
</p></div>
1047 <div class=
"paragraph"><p>But if you try to push, you will attempt to update the branch (that
1048 now points at A) with commit B. This does
<em>not
</em> fast-forward. If you did
1049 so, the changes introduced by commit A will be lost, because everybody
1050 will now start building on top of B.
</p></div>
1051 <div class=
"paragraph"><p>The command by default does not allow an update that is not a fast-forward
1052 to prevent such loss of history.
</p></div>
1053 <div class=
"paragraph"><p>If you do not want to lose your work (history from X to B) nor the work by
1054 the other person (history from X to A), you would need to first fetch the
1055 history from the repository, create a history that contains changes done
1056 by both parties, and push the result back.
</p></div>
1057 <div class=
"paragraph"><p>You can perform
"git pull", resolve potential conflicts, and
"git push"
1058 the result. A
"git pull" will create a merge commit C between commits A
1060 <div class=
"listingblock">
1061 <div class=
"content">
1066 <div class=
"paragraph"><p>Updating A with the resulting merge commit will fast-forward and your
1067 push will be accepted.
</p></div>
1068 <div class=
"paragraph"><p>Alternatively, you can rebase your change between X and B on top of A,
1069 with
"git pull --rebase", and push the result back. The rebase will
1070 create a new commit D that builds the change between X and B on top of
1072 <div class=
"listingblock">
1073 <div class=
"content">
1078 <div class=
"paragraph"><p>Again, updating A with this commit will fast-forward and your push will be
1080 <div class=
"paragraph"><p>There is another common situation where you may encounter non-fast-forward
1081 rejection when you try to push, and it is possible even when you are
1082 pushing into a repository nobody else pushes into. After you push commit
1083 A yourself (in the first picture in this section), replace it with
"git
1084 commit --amend" to produce commit B, and you try to push it out, because
1085 forgot that you have pushed A out already. In such a case, and only if
1086 you are certain that nobody in the meantime fetched your earlier commit A
1087 (and started building on top of it), you can run
"git push --force" to
1088 overwrite it. In other words,
"git push --force" is a method reserved for
1089 a case where you do mean to lose history.
</p></div>
1091 <h2 id=
"_examples">Examples
</h2>
1092 <div class=
"sectionbody">
1093 <div class=
"dlist"><dl>
1094 <dt class=
"hdlist1">
1099 Works like
<tt>git push
<remote
></tt>, where
<remote
> is the
1100 current branch
’s remote (or
<tt>origin
</tt>, if no remote is
1101 configured for the current branch).
1104 <dt class=
"hdlist1">
1109 Without additional configuration, works like
1110 <tt>git push origin :
</tt>.
1112 <div class=
"paragraph"><p>The default behavior of this command when no
<refspec
> is given can be
1113 configured by setting the
<tt>push
</tt> option of the remote.
</p></div>
1114 <div class=
"paragraph"><p>For example, to default to pushing only the current branch to
<tt>origin
</tt>
1115 use
<tt>git config remote.origin.push HEAD
</tt>. Any valid
<refspec
> (like
1116 the ones in the examples below) can be configured as the default for
1117 <tt>git push origin
</tt>.
</p></div>
1118 <div class=
"dlist"><dl>
1119 <dt class=
"hdlist1">
1124 Push
"matching" branches to
<tt>origin
</tt>. See
1125 <refspec
> in the
<a href=
"#OPTIONS">OPTIONS
</a> section above for a
1126 description of
"matching" branches.
1131 <dt class=
"hdlist1">
1132 git push origin master
1136 Find a ref that matches
<tt>master
</tt> in the source repository
1137 (most likely, it would find
<tt>refs/heads/master
</tt>), and update
1138 the same ref (e.g.
<tt>refs/heads/master
</tt>) in
<tt>origin
</tt> repository
1139 with it. If
<tt>master
</tt> did not exist remotely, it would be
1143 <dt class=
"hdlist1">
1144 git push origin HEAD
1148 A handy way to push the current branch to the same name on the
1152 <dt class=
"hdlist1">
1153 git push origin master:satellite/master dev:satellite/dev
1157 Use the source ref that matches
<tt>master
</tt> (e.g.
<tt>refs/heads/master
</tt>)
1158 to update the ref that matches
<tt>satellite/master
</tt> (most probably
1159 <tt>refs/remotes/satellite/master
</tt>) in the
<tt>origin
</tt> repository, then
1160 do the same for
<tt>dev
</tt> and
<tt>satellite/dev
</tt>.
1163 <dt class=
"hdlist1">
1164 git push origin HEAD:master
1168 Push the current branch to the remote ref matching
<tt>master
</tt> in the
1169 <tt>origin
</tt> repository. This form is convenient to push the current
1170 branch without thinking about its local name.
1173 <dt class=
"hdlist1">
1174 git push origin master:refs/heads/experimental
1178 Create the branch
<tt>experimental
</tt> in the
<tt>origin
</tt> repository
1179 by copying the current
<tt>master
</tt> branch. This form is only
1180 needed to create a new branch or tag in the remote repository when
1181 the local name and the remote name are different; otherwise,
1182 the ref name on its own will work.
1185 <dt class=
"hdlist1">
1186 git push origin :experimental
1190 Find a ref that matches
<tt>experimental
</tt> in the
<tt>origin
</tt> repository
1191 (e.g.
<tt>refs/heads/experimental
</tt>), and delete it.
1194 <dt class=
"hdlist1">
1195 git push origin
+dev:master
1199 Update the origin repository
’s master branch with the dev branch,
1200 allowing non-fast-forward updates.
<strong>This can leave unreferenced
1201 commits dangling in the origin repository.
</strong> Consider the
1202 following situation, where a fast-forward is not possible:
1204 <div class=
"listingblock">
1205 <div class=
"content">
1206 <pre><tt> o---o---o---A---B origin/master
1208 X---Y---Z dev
</tt></pre>
1210 <div class=
"paragraph"><p>The above command would change the origin repository to
</p></div>
1211 <div class=
"listingblock">
1212 <div class=
"content">
1213 <pre><tt> A---B (unnamed branch)
1215 o---o---o---X---Y---Z master
</tt></pre>
1217 <div class=
"paragraph"><p>Commits A and B would no longer belong to a branch with a symbolic name,
1218 and so would be unreachable. As such, these commits would be removed by
1219 a
<tt>git gc
</tt> command on the origin repository.
</p></div>
1223 <h2 id=
"_git">GIT
</h2>
1224 <div class=
"sectionbody">
1225 <div class=
"paragraph"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
1228 <div id=
"footer-text">
1229 Last updated
2011-
03-
15 23:
30:
14 UTC