1 <?xml version="1.0" encoding="UTF-8"?>
\r
2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
\r
4 <article lang="en" id="git-push(1)">
\r
6 <title>git-push(1)</title>
\r
8 <primary>git-push(1)</primary>
\r
11 <simplesect id="_name">
\r
13 <simpara>git-push - Update remote refs along with associated objects</simpara>
\r
15 <simplesect id="_synopsis">
\r
16 <title>SYNOPSIS</title>
\r
18 <literallayout><emphasis>git push</emphasis> [--all | --mirror] [--dry-run] [--tags] [--receive-pack=<git-receive-pack>]
\r
19 [--repo=<repository>] [-f | --force] [-v | --verbose]
\r
20 [<repository> <refspec>…]</literallayout>
\r
23 <simplesect id="_description">
\r
24 <title>DESCRIPTION</title>
\r
25 <simpara>Updates remote refs using local refs, while sending objects
\r
26 necessary to complete the given refs.</simpara>
\r
27 <simpara>You can make interesting things happen to a repository
\r
28 every time you push into it, by setting up <emphasis>hooks</emphasis> there. See
\r
29 documentation for <xref linkend="git-receive-pack(1)"/>.</simpara>
\r
31 <simplesect id="_options">
\r
32 <title>OPTIONS</title>
\r
40 The "remote" repository that is destination of a push
\r
41 operation. This parameter can be either a URL
\r
42 (see the section <link linkend="URLS">GIT URLS</link> below) or the name
\r
43 of a remote (see the section <link linkend="REMOTES">REMOTES</link> below).
\r
49 <refspec>…
\r
53 The format of a <refspec> parameter is an optional plus
\r
54 <literal>+</literal>, followed by the source ref <src>, followed
\r
55 by a colon <literal>:</literal>, followed by the destination ref <dst>.
\r
56 It is used to specify with what <src> object the <dst> ref
\r
57 in the remote repository is to be updated.
\r
59 <simpara>The <src> is often the name of the branch you would want to push, but
\r
60 it can be any arbitrary "SHA-1 expression", such as <literal>master~4</literal> or
\r
61 <literal>HEAD</literal> (see <xref linkend="git-rev-parse(1)"/>).</simpara>
\r
62 <simpara>The <dst> tells which ref on the remote side is updated with this
\r
63 push. Arbitrary expressions cannot be used here, an actual ref must
\r
64 be named. If <literal>:</literal><dst> is omitted, the same ref as <src> will be
\r
66 <simpara>The object referenced by <src> is used to fast forward the ref <dst>
\r
67 on the remote side. If the optional leading plus <literal>+</literal> is used, the
\r
68 remote ref is updated even if it does not result in a fast forward
\r
70 <simpara><literal>tag <tag></literal> means the same as <literal>refs/tags/<tag>:refs/tags/<tag></literal>.</simpara>
\r
71 <simpara>Pushing an empty <src> allows you to delete the <dst> ref from
\r
72 the remote repository.</simpara>
\r
73 <simpara>The special refspec <literal>:</literal> (or <literal>+:</literal> to allow non-fast forward updates)
\r
74 directs git to push "matching" branches: for every branch that exists on
\r
75 the local side, the remote side is updated if a branch of the same name
\r
76 already exists on the remote side. This is the default operation mode
\r
77 if no explicit refspec is found (that is neither on the command line
\r
78 nor in any Push line of the corresponding remotes file---see below).</simpara>
\r
87 Instead of naming each ref to push, specifies that all
\r
88 refs under <literal>$GIT_DIR/refs/heads/</literal> be pushed.
\r
98 Instead of naming each ref to push, specifies that all
\r
99 refs under <literal>$GIT_DIR/refs/</literal> (which includes but is not
\r
100 limited to <literal>refs/heads/</literal>, <literal>refs/remotes/</literal>, and <literal>refs/tags/</literal>)
\r
101 be mirrored to the remote repository. Newly created local
\r
102 refs will be pushed to the remote end, locally updated refs
\r
103 will be force updated on the remote end, and deleted refs
\r
104 will be removed from the remote end. This is the default
\r
105 if the configuration option <literal>remote.<remote>.mirror</literal> is
\r
116 Do everything except actually send the updates.
\r
126 All refs under <literal>$GIT_DIR/refs/tags</literal> are pushed, in
\r
127 addition to refspecs explicitly listed on the command
\r
134 --receive-pack=<git-receive-pack>
\r
137 --exec=<git-receive-pack>
\r
141 Path to the <emphasis>git-receive-pack</emphasis> program on the remote
\r
142 end. Sometimes useful when pushing to a remote
\r
143 repository over ssh, and you do not have the program in
\r
144 a directory on the default $PATH.
\r
157 Usually, the command refuses to update a remote ref that is
\r
158 not an ancestor of the local ref used to overwrite it.
\r
159 This flag disables the check. This can cause the
\r
160 remote repository to lose commits; use it with care.
\r
166 --repo=<repository>
\r
170 This option is only relevant if no <repository> argument is
\r
171 passed in the invocation. In this case, <emphasis>git-push</emphasis> derives the
\r
172 remote name from the current branch: If it tracks a remote
\r
173 branch, then that remote repository is pushed to. Otherwise,
\r
174 the name "origin" is used. For this latter case, this option
\r
175 can be used to override the name "origin". In other words,
\r
176 the difference between these two commands
\r
178 <literallayout>git push public #1
\r
179 git push --repo=public #2</literallayout>
\r
180 <simpara>is that #1 always pushes to "public" whereas #2 pushes to "public"
\r
181 only if the current branch does not track a remote branch. This is
\r
182 useful if you write an alias or script around <emphasis>git-push</emphasis>.</simpara>
\r
194 These options are passed to <emphasis>git-send-pack</emphasis>. Thin
\r
195 transfer spends extra cycles to minimize the number of
\r
196 objects to be sent and meant to be used on slower connection.
\r
215 <simplesect id="_git_urls_anchor_id_urls_xreflabel_urls">
\r
216 <title>GIT URLS<anchor id="URLS" xreflabel="[URLS]"/></title>
\r
217 <simpara>One of the following notations can be used
\r
218 to name the remote repository:</simpara>
\r
223 rsync://host.xz/path/to/repo.git/
\r
228 <ulink url="http://host.xz[:port]/path/to/repo.git/">http://host.xz[:port]/path/to/repo.git/</ulink>
\r
233 <ulink url="https://host.xz[:port]/path/to/repo.git/">https://host.xz[:port]/path/to/repo.git/</ulink>
\r
238 git://host.xz[:port]/path/to/repo.git/
\r
243 git://host.xz[:port]/~user/path/to/repo.git/
\r
248 ssh://[user@]host.xz[:port]/path/to/repo.git/
\r
253 ssh://[user@]host.xz/path/to/repo.git/
\r
258 ssh://[user@]host.xz/~user/path/to/repo.git/
\r
263 ssh://[user@]host.xz/~/path/to/repo.git
\r
268 <simpara>SSH is the default transport protocol over the network. You can
\r
269 optionally specify which user to log-in as, and an alternate,
\r
270 scp-like syntax is also supported. Both syntaxes support
\r
271 username expansion, as does the native git protocol, but
\r
272 only the former supports port specification. The following
\r
273 three are identical to the last three above, respectively:</simpara>
\r
278 [user@]host.xz:/path/to/repo.git/
\r
283 [user@]host.xz:~user/path/to/repo.git/
\r
288 [user@]host.xz:path/to/repo.git
\r
293 <simpara>To sync with a local directory, you can use:</simpara>
\r
303 <ulink url="file:///path/to/repo.git/">file:///path/to/repo.git/</ulink>
\r
308 <simpara>They are mostly equivalent, except when cloning. See
\r
309 <xref linkend="git-clone(1)"/> for details.</simpara>
\r
310 <simpara>If there are a large number of similarly-named remote repositories and
\r
311 you want to use a different format for them (such that the URLs you
\r
312 use will be rewritten into URLs that work), you can create a
\r
313 configuration section of the form:</simpara>
\r
314 <literallayout> [url "<actual url base>"]
\r
315 insteadOf = <other url base></literallayout>
\r
316 <simpara>For example, with this:</simpara>
\r
317 <literallayout> [url "git://git.host.xz/"]
\r
318 insteadOf = host.xz:/path/to/
\r
319 insteadOf = work:</literallayout>
\r
320 <simpara>a URL like "work:repo.git" or like "host.xz:/path/to/repo.git" will be
\r
321 rewritten in any context that takes a URL to be "git://git.host.xz/repo.git".</simpara>
\r
323 <simplesect id="_remotes_anchor_id_remotes_xreflabel_remotes">
\r
324 <title>REMOTES<anchor id="REMOTES" xreflabel="[REMOTES]"/></title>
\r
325 <simpara>The name of one of the following can be used instead
\r
326 of a URL as <literal><repository></literal> argument:</simpara>
\r
330 a remote in the git configuration file: <literal>$GIT_DIR/config</literal>,
\r
335 a file in the <literal>$GIT_DIR/remotes</literal> directory, or
\r
340 a file in the <literal>$GIT_DIR/branches</literal> directory.
\r
344 <simpara>All of these also allow you to omit the refspec from the command line
\r
345 because they each contain a refspec which git will use by default.</simpara>
\r
346 <simplesect id="_named_remote_in_configuration_file">
\r
347 <title>Named remote in configuration file</title>
\r
348 <simpara>You can choose to provide the name of a remote which you had previously
\r
349 configured using <xref linkend="git-remote(1)"/>, <xref linkend="git-config(1)"/>
\r
350 or even by a manual edit to the <literal>$GIT_DIR/config</literal> file. The URL of
\r
351 this remote will be used to access the repository. The refspec
\r
352 of this remote will be used by default when you do
\r
353 not provide a refspec on the command line. The entry in the
\r
354 config file would appear like this:</simpara>
\r
355 <literallayout> [remote "<name>"]
\r
357 push = <refspec>
\r
358 fetch = <refspec></literallayout>
\r
360 <simplesect id="_named_file_in_literal_git_dir_remotes_literal">
\r
361 <title>Named file in <literal>$GIT_DIR/remotes</literal></title>
\r
362 <simpara>You can choose to provide the name of a
\r
363 file in <literal>$GIT_DIR/remotes</literal>. The URL
\r
364 in this file will be used to access the repository. The refspec
\r
365 in this file will be used as default when you do not
\r
366 provide a refspec on the command line. This file should have the
\r
367 following format:</simpara>
\r
368 <literallayout> URL: one of the above URL format
\r
369 Push: <refspec>
\r
370 Pull: <refspec></literallayout>
\r
371 <simpara><literal>Push:</literal> lines are used by <emphasis>git-push</emphasis> and
\r
372 <literal>Pull:</literal> lines are used by <emphasis>git-pull</emphasis> and <emphasis>git-fetch</emphasis>.
\r
373 Multiple <literal>Push:</literal> and <literal>Pull:</literal> lines may
\r
374 be specified for additional branch mappings.</simpara>
\r
376 <simplesect id="_named_file_in_literal_git_dir_branches_literal">
\r
377 <title>Named file in <literal>$GIT_DIR/branches</literal></title>
\r
378 <simpara>You can choose to provide the name of a
\r
379 file in <literal>$GIT_DIR/branches</literal>.
\r
380 The URL in this file will be used to access the repository.
\r
381 This file should have the following format:</simpara>
\r
382 <literallayout> <url>#<head></literallayout>
\r
383 <simpara><literal><url></literal> is required; <literal>#<head></literal> is optional.</simpara>
\r
384 <simpara>Depending on the operation, git will use one of the following
\r
385 refspecs, if you don’t provide one on the command line.
\r
386 <literal><branch></literal> is the name of this file in <literal>$GIT_DIR/branches</literal> and
\r
387 <literal><head></literal> defaults to <literal>master</literal>.</simpara>
\r
388 <simpara>git fetch uses:</simpara>
\r
389 <literallayout> refs/heads/<head>:refs/heads/<branch></literallayout>
\r
390 <simpara>git push uses:</simpara>
\r
391 <literallayout> HEAD:refs/heads/<head></literallayout>
\r
394 <simplesect id="_output">
\r
395 <title>OUTPUT</title>
\r
396 <simpara>The output of "git push" depends on the transport method used; this
\r
397 section describes the output when pushing over the git protocol (either
\r
398 locally or via ssh).</simpara>
\r
399 <simpara>The status of the push is output in tabular form, with each line
\r
400 representing the status of a single ref. Each line is of the form:</simpara>
\r
401 <literallayout> <flag> <summary> <from> -> <to> (<reason>)</literallayout>
\r
409 A single character indicating the status of the ref. This is
\r
410 blank for a successfully pushed ref, <literal>!</literal> for a ref that was
\r
411 rejected or failed to push, and <emphasis>=</emphasis> for a ref that was up to
\r
412 date and did not need pushing (note that the status of up to
\r
413 date refs is shown only when <literal>git push</literal> is running verbosely).
\r
423 For a successfully pushed ref, the summary shows the old and new
\r
424 values of the ref in a form suitable for using as an argument to
\r
425 <literal>git log</literal> (this is <literal><old>..<new></literal> in most cases, and
\r
426 <literal><old>…<new></literal> for forced non-fast forward updates). For a
\r
427 failed update, more details are given for the failure.
\r
428 The string <literal>rejected</literal> indicates that git did not try to send the
\r
429 ref at all (typically because it is not a fast forward). The
\r
430 string <literal>remote rejected</literal> indicates that the remote end refused
\r
431 the update; this rejection is typically caused by a hook on the
\r
432 remote side. The string <literal>remote failure</literal> indicates that the
\r
433 remote end did not report the successful update of the ref
\r
434 (perhaps because of a temporary error on the remote side, a
\r
435 break in the network connection, or other transient error).
\r
445 The name of the local ref being pushed, minus its
\r
446 <literal>refs/<type>/</literal> prefix. In the case of deletion, the
\r
447 name of the local ref is omitted.
\r
457 The name of the remote ref being updated, minus its
\r
458 <literal>refs/<type>/</literal> prefix.
\r
468 A human-readable explanation. In the case of successfully pushed
\r
469 refs, no explanation is needed. For a failed ref, the reason for
\r
470 failure is described.
\r
476 <simplesect id="_examples">
\r
477 <title>Examples</title>
\r
481 git push origin master
\r
485 Find a ref that matches <literal>master</literal> in the source repository
\r
486 (most likely, it would find <literal>refs/heads/master</literal>), and update
\r
487 the same ref (e.g. <literal>refs/heads/master</literal>) in <literal>origin</literal> repository
\r
488 with it. If <literal>master</literal> did not exist remotely, it would be
\r
495 git push origin HEAD
\r
499 A handy way to push the current branch to the same name on the
\r
506 git push origin master:satellite/master dev:satellite/dev
\r
510 Use the source ref that matches <literal>master</literal> (e.g. <literal>refs/heads/master</literal>)
\r
511 to update the ref that matches <literal>satellite/master</literal> (most probably
\r
512 <literal>refs/remotes/satellite/master</literal>) in the <literal>origin</literal> repository, then
\r
513 do the same for <literal>dev</literal> and <literal>satellite/dev</literal>.
\r
519 git push origin HEAD:master
\r
523 Push the current branch to the remote ref matching <literal>master</literal> in the
\r
524 <literal>origin</literal> repository. This form is convenient to push the current
\r
525 branch without thinking about its local name.
\r
531 git push origin master:refs/heads/experimental
\r
535 Create the branch <literal>experimental</literal> in the <literal>origin</literal> repository
\r
536 by copying the current <literal>master</literal> branch. This form is only
\r
537 needed to create a new branch or tag in the remote repository when
\r
538 the local name and the remote name are different; otherwise,
\r
539 the ref name on its own will work.
\r
545 git push origin :experimental
\r
549 Find a ref that matches <literal>experimental</literal> in the <literal>origin</literal> repository
\r
550 (e.g. <literal>refs/heads/experimental</literal>), and delete it.
\r
556 <simplesect id="_author">
\r
557 <title>Author</title>
\r
558 <simpara>Written by Junio C Hamano <<ulink url="mailto:gitster@pobox.com">gitster@pobox.com</ulink>>, later rewritten in C
\r
559 by Linus Torvalds <<ulink url="mailto:torvalds@osdl.org">torvalds@osdl.org</ulink>></simpara>
\r
561 <simplesect id="_documentation">
\r
562 <title>Documentation</title>
\r
563 <simpara>Documentation by Junio C Hamano and the git-list <<ulink url="mailto:git@vger.kernel.org">git@vger.kernel.org</ulink>>.</simpara>
\r
565 <simplesect id="_git">
\r
567 <simpara>Part of the <xref linkend="git(1)"/> suite</simpara>
\r