<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">

<article lang="en" id="git-push(1)">
<articleinfo>
    <title>git-push(1)</title>
        <indexterm>
                <primary>git-push(1)</primary>
        </indexterm>
</articleinfo>
<simplesect id="_name">
<title>NAME</title>
<simpara>git-push - Update remote refs along with associated objects</simpara>
</simplesect>
<simplesect id="_synopsis">
<title>SYNOPSIS</title>
<blockquote>
<literallayout><emphasis>git push</emphasis> [--all | --mirror] [--dry-run] [--tags] [--receive-pack=&lt;git-receive-pack&gt;]
           [--repo=&lt;repository&gt;] [-f | --force] [-v | --verbose]
           [&lt;repository&gt; &lt;refspec&gt;&#8230;]</literallayout>
</blockquote>
</simplesect>
<simplesect id="_description">
<title>DESCRIPTION</title>
<simpara>Updates remote refs using local refs, while sending objects
necessary to complete the given refs.</simpara>
<simpara>You can make interesting things happen to a repository
every time you push into it, by setting up <emphasis>hooks</emphasis> there.  See
documentation for <xref linkend="git-receive-pack(1)"/>.</simpara>
</simplesect>
<simplesect id="_options">
<title>OPTIONS</title>
<variablelist>
<varlistentry>
<term>
&lt;repository&gt;
</term>
<listitem>
<simpara>
        The "remote" repository that is destination of a push
        operation.  This parameter can be either a URL
        (see the section <link linkend="URLS">GIT URLS</link> below) or the name
        of a remote (see the section <link linkend="REMOTES">REMOTES</link> below).
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
&lt;refspec&gt;&#8230;
</term>
<listitem>
<simpara>
        The format of a &lt;refspec&gt; parameter is an optional plus
        <literal>&#43;</literal>, followed by the source ref &lt;src&gt;, followed
        by a colon <literal>:</literal>, followed by the destination ref &lt;dst&gt;.
        It is used to specify with what &lt;src&gt; object the &lt;dst&gt; ref
        in the remote repository is to be updated.
</simpara>
<simpara>The &lt;src&gt; is often the name of the branch you would want to push, but
it can be any arbitrary "SHA-1 expression", such as <literal>master~4</literal> or
<literal>HEAD</literal> (see <xref linkend="git-rev-parse(1)"/>).</simpara>
<simpara>The &lt;dst&gt; tells which ref on the remote side is updated with this
push. Arbitrary expressions cannot be used here, an actual ref must
be named. If <literal>:</literal>&lt;dst&gt; is omitted, the same ref as &lt;src&gt; will be
updated.</simpara>
<simpara>The object referenced by &lt;src&gt; is used to fast forward the ref &lt;dst&gt;
on the remote side. If the optional leading plus <literal>&#43;</literal> is used, the
remote ref is updated even if it does not result in a fast forward
update.</simpara>
<simpara><literal>tag &lt;tag&gt;</literal> means the same as <literal>refs/tags/&lt;tag&gt;:refs/tags/&lt;tag&gt;</literal>.</simpara>
<simpara>Pushing an empty &lt;src&gt; allows you to delete the &lt;dst&gt; ref from
the remote repository.</simpara>
<simpara>The special refspec <literal>:</literal> (or <literal>+:</literal> to allow non-fast forward updates)
directs git to push "matching" branches: for every branch that exists on
the local side, the remote side is updated if a branch of the same name
already exists on the remote side.  This is the default operation mode
if no explicit refspec is found (that is neither on the command line
nor in any Push line of the corresponding remotes file---see below).</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--all
</term>
<listitem>
<simpara>
        Instead of naming each ref to push, specifies that all
        refs under <literal>$GIT_DIR/refs/heads/</literal> be pushed.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--mirror
</term>
<listitem>
<simpara>
        Instead of naming each ref to push, specifies that all
        refs under <literal>$GIT_DIR/refs/</literal> (which includes but is not
        limited to <literal>refs/heads/</literal>, <literal>refs/remotes/</literal>, and <literal>refs/tags/</literal>)
        be mirrored to the remote repository.  Newly created local
        refs will be pushed to the remote end, locally updated refs
        will be force updated on the remote end, and deleted refs
        will be removed from the remote end.  This is the default
        if the configuration option <literal>remote.&lt;remote&gt;.mirror</literal> is
        set.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--dry-run
</term>
<listitem>
<simpara>
        Do everything except actually send the updates.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--tags
</term>
<listitem>
<simpara>
        All refs under <literal>$GIT_DIR/refs/tags</literal> are pushed, in
        addition to refspecs explicitly listed on the command
        line.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--receive-pack=&lt;git-receive-pack&gt;
</term>
<term>
--exec=&lt;git-receive-pack&gt;
</term>
<listitem>
<simpara>
        Path to the <emphasis>git-receive-pack</emphasis> program on the remote
        end.  Sometimes useful when pushing to a remote
        repository over ssh, and you do not have the program in
        a directory on the default $PATH.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-f
</term>
<term>
--force
</term>
<listitem>
<simpara>
        Usually, the command refuses to update a remote ref that is
        not an ancestor of the local ref used to overwrite it.
        This flag disables the check.  This can cause the
        remote repository to lose commits; use it with care.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--repo=&lt;repository&gt;
</term>
<listitem>
<simpara>
        This option is only relevant if no &lt;repository&gt; argument is
        passed in the invocation. In this case, <emphasis>git-push</emphasis> derives the
        remote name from the current branch: If it tracks a remote
        branch, then that remote repository is pushed to. Otherwise,
        the name "origin" is used. For this latter case, this option
        can be used to override the name "origin". In other words,
        the difference between these two commands
</simpara>
<literallayout>git push public         #1
git push --repo=public  #2</literallayout>
<simpara>is that #1 always pushes to "public" whereas #2 pushes to "public"
only if the current branch does not track a remote branch. This is
useful if you write an alias or script around <emphasis>git-push</emphasis>.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--thin
</term>
<term>
--no-thin
</term>
<listitem>
<simpara>
        These options are passed to <emphasis>git-send-pack</emphasis>.  Thin
        transfer spends extra cycles to minimize the number of
        objects to be sent and meant to be used on slower connection.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-v
</term>
<term>
--verbose
</term>
<listitem>
<simpara>
        Run verbosely.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</simplesect>
<simplesect id="_git_urls_anchor_id_urls_xreflabel_urls">
<title>GIT URLS<anchor id="URLS" xreflabel="[URLS]"/></title>
<simpara>One of the following notations can be used
to name the remote repository:</simpara>
<informalexample>
<itemizedlist>
<listitem>
<simpara>
rsync://host.xz/path/to/repo.git/
</simpara>
</listitem>
<listitem>
<simpara>
<ulink url="http://host.xz&#91;:port&#93;/path/to/repo.git/">http://host.xz&#91;:port&#93;/path/to/repo.git/</ulink>
</simpara>
</listitem>
<listitem>
<simpara>
<ulink url="https://host.xz&#91;:port&#93;/path/to/repo.git/">https://host.xz&#91;:port&#93;/path/to/repo.git/</ulink>
</simpara>
</listitem>
<listitem>
<simpara>
git://host.xz&#91;:port&#93;/path/to/repo.git/
</simpara>
</listitem>
<listitem>
<simpara>
git://host.xz&#91;:port&#93;/~user/path/to/repo.git/
</simpara>
</listitem>
<listitem>
<simpara>
ssh://&#91;user@&#93;host.xz&#91;:port&#93;/path/to/repo.git/
</simpara>
</listitem>
<listitem>
<simpara>
ssh://&#91;user@&#93;host.xz/path/to/repo.git/
</simpara>
</listitem>
<listitem>
<simpara>
ssh://&#91;user@&#93;host.xz/~user/path/to/repo.git/
</simpara>
</listitem>
<listitem>
<simpara>
ssh://&#91;user@&#93;host.xz/~/path/to/repo.git
</simpara>
</listitem>
</itemizedlist>
</informalexample>
<simpara>SSH is the default transport protocol over the network.  You can
optionally specify which user to log-in as, and an alternate,
scp-like syntax is also supported.  Both syntaxes support
username expansion, as does the native git protocol, but
only the former supports port specification. The following
three are identical to the last three above, respectively:</simpara>
<informalexample>
<itemizedlist>
<listitem>
<simpara>
&#91;user@&#93;host.xz:/path/to/repo.git/
</simpara>
</listitem>
<listitem>
<simpara>
&#91;user@&#93;host.xz:~user/path/to/repo.git/
</simpara>
</listitem>
<listitem>
<simpara>
&#91;user@&#93;host.xz:path/to/repo.git
</simpara>
</listitem>
</itemizedlist>
</informalexample>
<simpara>To sync with a local directory, you can use:</simpara>
<informalexample>
<itemizedlist>
<listitem>
<simpara>
/path/to/repo.git/
</simpara>
</listitem>
<listitem>
<simpara>
<ulink url="file:///path/to/repo.git/">file:///path/to/repo.git/</ulink>
</simpara>
</listitem>
</itemizedlist>
</informalexample>
<simpara>They are mostly equivalent, except when cloning.  See
<xref linkend="git-clone(1)"/> for details.</simpara>
<simpara>If there are a large number of similarly-named remote repositories and
you want to use a different format for them (such that the URLs you
use will be rewritten into URLs that work), you can create a
configuration section of the form:</simpara>
<literallayout>        [url "&lt;actual url base&gt;"]
                insteadOf = &lt;other url base&gt;</literallayout>
<simpara>For example, with this:</simpara>
<literallayout>        [url "git://git.host.xz/"]
                insteadOf = host.xz:/path/to/
                insteadOf = work:</literallayout>
<simpara>a URL like "work:repo.git" or like "host.xz:/path/to/repo.git" will be
rewritten in any context that takes a URL to be "git://git.host.xz/repo.git".</simpara>
</simplesect>
<simplesect id="_remotes_anchor_id_remotes_xreflabel_remotes">
<title>REMOTES<anchor id="REMOTES" xreflabel="[REMOTES]"/></title>
<simpara>The name of one of the following can be used instead
of a URL as <literal>&lt;repository&gt;</literal> argument:</simpara>
<itemizedlist>
<listitem>
<simpara>
a remote in the git configuration file: <literal>$GIT_DIR/config</literal>,
</simpara>
</listitem>
<listitem>
<simpara>
a file in the <literal>$GIT_DIR/remotes</literal> directory, or
</simpara>
</listitem>
<listitem>
<simpara>
a file in the <literal>$GIT_DIR/branches</literal> directory.
</simpara>
</listitem>
</itemizedlist>
<simpara>All of these also allow you to omit the refspec from the command line
because they each contain a refspec which git will use by default.</simpara>
<simplesect id="_named_remote_in_configuration_file">
<title>Named remote in configuration file</title>
<simpara>You can choose to provide the name of a remote which you had previously
configured using <xref linkend="git-remote(1)"/>, <xref linkend="git-config(1)"/>
or even by a manual edit to the <literal>$GIT_DIR/config</literal> file.  The URL of
this remote will be used to access the repository.  The refspec
of this remote will be used by default when you do
not provide a refspec on the command line.  The entry in the
config file would appear like this:</simpara>
<literallayout>        [remote "&lt;name&gt;"]
                url = &lt;url&gt;
                push = &lt;refspec&gt;
                fetch = &lt;refspec&gt;</literallayout>
</simplesect>
<simplesect id="_named_file_in_literal_git_dir_remotes_literal">
<title>Named file in <literal>$GIT_DIR/remotes</literal></title>
<simpara>You can choose to provide the name of a
file in <literal>$GIT_DIR/remotes</literal>.  The URL
in this file will be used to access the repository.  The refspec
in this file will be used as default when you do not
provide a refspec on the command line.  This file should have the
following format:</simpara>
<literallayout>        URL: one of the above URL format
        Push: &lt;refspec&gt;
        Pull: &lt;refspec&gt;</literallayout>
<simpara><literal>Push:</literal> lines are used by <emphasis>git-push</emphasis> and
<literal>Pull:</literal> lines are used by <emphasis>git-pull</emphasis> and <emphasis>git-fetch</emphasis>.
Multiple <literal>Push:</literal> and <literal>Pull:</literal> lines may
be specified for additional branch mappings.</simpara>
</simplesect>
<simplesect id="_named_file_in_literal_git_dir_branches_literal">
<title>Named file in <literal>$GIT_DIR/branches</literal></title>
<simpara>You can choose to provide the name of a
file in <literal>$GIT_DIR/branches</literal>.
The URL in this file will be used to access the repository.
This file should have the following format:</simpara>
<literallayout>        &lt;url&gt;#&lt;head&gt;</literallayout>
<simpara><literal>&lt;url&gt;</literal> is required; <literal>#&lt;head&gt;</literal> is optional.</simpara>
<simpara>Depending on the operation, git will use one of the following
refspecs, if you don&#8217;t provide one on the command line.
<literal>&lt;branch&gt;</literal> is the name of this file in <literal>$GIT_DIR/branches</literal> and
<literal>&lt;head&gt;</literal> defaults to <literal>master</literal>.</simpara>
<simpara>git fetch uses:</simpara>
<literallayout>        refs/heads/&lt;head&gt;:refs/heads/&lt;branch&gt;</literallayout>
<simpara>git push uses:</simpara>
<literallayout>        HEAD:refs/heads/&lt;head&gt;</literallayout>
</simplesect>
</simplesect>
<simplesect id="_output">
<title>OUTPUT</title>
<simpara>The output of "git push" depends on the transport method used; this
section describes the output when pushing over the git protocol (either
locally or via ssh).</simpara>
<simpara>The status of the push is output in tabular form, with each line
representing the status of a single ref. Each line is of the form:</simpara>
<literallayout> &lt;flag&gt; &lt;summary&gt; &lt;from&gt; -&gt; &lt;to&gt; (&lt;reason&gt;)</literallayout>
<variablelist>
<varlistentry>
<term>
flag
</term>
<listitem>
<simpara>
        A single character indicating the status of the ref. This is
        blank for a successfully pushed ref, <literal>!</literal> for a ref that was
        rejected or failed to push, and <emphasis>=</emphasis> for a ref that was up to
        date and did not need pushing (note that the status of up to
        date refs is shown only when <literal>git push</literal> is running verbosely).
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
summary
</term>
<listitem>
<simpara>
        For a successfully pushed ref, the summary shows the old and new
        values of the ref in a form suitable for using as an argument to
        <literal>git log</literal> (this is <literal>&lt;old&gt;..&lt;new&gt;</literal> in most cases, and
        <literal>&lt;old&gt;&#8230;&lt;new&gt;</literal> for forced non-fast forward updates). For a
        failed update, more details are given for the failure.
        The string <literal>rejected</literal> indicates that git did not try to send the
        ref at all (typically because it is not a fast forward). The
        string <literal>remote rejected</literal> indicates that the remote end refused
        the update; this rejection is typically caused by a hook on the
        remote side. The string <literal>remote failure</literal> indicates that the
        remote end did not report the successful update of the ref
        (perhaps because of a temporary error on the remote side, a
        break in the network connection, or other transient error).
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
from
</term>
<listitem>
<simpara>
        The name of the local ref being pushed, minus its
        <literal>refs/&lt;type&gt;/</literal> prefix. In the case of deletion, the
        name of the local ref is omitted.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
to
</term>
<listitem>
<simpara>
        The name of the remote ref being updated, minus its
        <literal>refs/&lt;type&gt;/</literal> prefix.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
reason
</term>
<listitem>
<simpara>
        A human-readable explanation. In the case of successfully pushed
        refs, no explanation is needed. For a failed ref, the reason for
        failure is described.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</simplesect>
<simplesect id="_examples">
<title>Examples</title>
<variablelist>
<varlistentry>
<term>
git push origin master
</term>
<listitem>
<simpara>
        Find a ref that matches <literal>master</literal> in the source repository
        (most likely, it would find <literal>refs/heads/master</literal>), and update
        the same ref (e.g. <literal>refs/heads/master</literal>) in <literal>origin</literal> repository
        with it.  If <literal>master</literal> did not exist remotely, it would be
        created.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
git push origin HEAD
</term>
<listitem>
<simpara>
        A handy way to push the current branch to the same name on the
        remote.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
git push origin master:satellite/master dev:satellite/dev
</term>
<listitem>
<simpara>
        Use the source ref that matches <literal>master</literal> (e.g. <literal>refs/heads/master</literal>)
        to update the ref that matches <literal>satellite/master</literal> (most probably
        <literal>refs/remotes/satellite/master</literal>) in the <literal>origin</literal> repository, then
        do the same for <literal>dev</literal> and <literal>satellite/dev</literal>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
git push origin HEAD:master
</term>
<listitem>
<simpara>
        Push the current branch to the remote ref matching <literal>master</literal> in the
        <literal>origin</literal> repository. This form is convenient to push the current
        branch without thinking about its local name.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
git push origin master:refs/heads/experimental
</term>
<listitem>
<simpara>
        Create the branch <literal>experimental</literal> in the <literal>origin</literal> repository
        by copying the current <literal>master</literal> branch.  This form is only
        needed to create a new branch or tag in the remote repository when
        the local name and the remote name are different; otherwise,
        the ref name on its own will work.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
git push origin :experimental
</term>
<listitem>
<simpara>
        Find a ref that matches <literal>experimental</literal> in the <literal>origin</literal> repository
        (e.g. <literal>refs/heads/experimental</literal>), and delete it.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</simplesect>
<simplesect id="_author">
<title>Author</title>
<simpara>Written by Junio C Hamano &lt;<ulink url="mailto:gitster@pobox.com">gitster@pobox.com</ulink>&gt;, later rewritten in C
by Linus Torvalds &lt;<ulink url="mailto:torvalds@osdl.org">torvalds@osdl.org</ulink>&gt;</simpara>
</simplesect>
<simplesect id="_documentation">
<title>Documentation</title>
<simpara>Documentation by Junio C Hamano and the git-list &lt;<ulink url="mailto:git@vger.kernel.org">git@vger.kernel.org</ulink>&gt;.</simpara>
</simplesect>
<simplesect id="_git">
<title>GIT</title>
<simpara>Part of the <xref linkend="git(1)"/> suite</simpara>
</simplesect>
</article>
