1GIT-PUSH(1)                       Git Manual                       GIT-PUSH(1)
2
3
4

NAME

6       git-push - Update remote refs along with associated objects
7

SYNOPSIS

9       git push [--all | --mirror | --tags] [--follow-tags] [--atomic] [-n | --dry-run] [--receive-pack=<git-receive-pack>]
10                  [--repo=<repository>] [-f | --force] [-d | --delete] [--prune] [-v | --verbose]
11                  [-u | --set-upstream] [-o <string> | --push-option=<string>]
12                  [--[no-]signed|--signed=(true|false|if-asked)]
13                  [--force-with-lease[=<refname>[:<expect>]]]
14                  [--no-verify] [<repository> [<refspec>...]]
15

DESCRIPTION

17       Updates remote refs using local refs, while sending objects necessary
18       to complete the given refs.
19
20       You can make interesting things happen to a repository every time you
21       push into it, by setting up hooks there. See documentation for git-
22       receive-pack(1).
23
24       When the command line does not specify where to push with the
25       <repository> argument, branch.*.remote configuration for the current
26       branch is consulted to determine where to push. If the configuration is
27       missing, it defaults to origin.
28
29       When the command line does not specify what to push with <refspec>...
30       arguments or --all, --mirror, --tags options, the command finds the
31       default <refspec> by consulting remote.*.push configuration, and if it
32       is not found, honors push.default configuration to decide what to push
33       (See git-config(1) for the meaning of push.default).
34
35       When neither the command-line nor the configuration specify what to
36       push, the default behavior is used, which corresponds to the simple
37       value for push.default: the current branch is pushed to the
38       corresponding upstream branch, but as a safety measure, the push is
39       aborted if the upstream branch does not have the same name as the local
40       one.
41

OPTIONS

43       <repository>
44           The "remote" repository that is destination of a push operation.
45           This parameter can be either a URL (see the section GIT URLS below)
46           or the name of a remote (see the section REMOTES below).
47
48       <refspec>...
49           Specify what destination ref to update with what source object. The
50           format of a <refspec> parameter is an optional plus +, followed by
51           the source object <src>, followed by a colon :, followed by the
52           destination ref <dst>.
53
54           The <src> is often the name of the branch you would want to push,
55           but it can be any arbitrary "SHA-1 expression", such as master~4 or
56           HEAD (see gitrevisions(7)).
57
58           The <dst> tells which ref on the remote side is updated with this
59           push. Arbitrary expressions cannot be used here, an actual ref must
60           be named. If git push [<repository>] without any <refspec> argument
61           is set to update some ref at the destination with <src> with
62           remote.<repository>.push configuration variable, :<dst> part can be
63           omitted—such a push will update a ref that <src> normally updates
64           without any <refspec> on the command line. Otherwise, missing
65           :<dst> means to update the same ref as the <src>.
66
67           If <dst> doesn’t start with refs/ (e.g.  refs/heads/master) we will
68           try to infer where in refs/* on the destination <repository> it
69           belongs based on the type of <src> being pushed and whether <dst>
70           is ambiguous.
71
72           ·   If <dst> unambiguously refers to a ref on the <repository>
73               remote, then push to that ref.
74
75           ·   If <src> resolves to a ref starting with refs/heads/ or
76               refs/tags/, then prepend that to <dst>.
77
78           ·   Other ambiguity resolutions might be added in the future, but
79               for now any other cases will error out with an error indicating
80               what we tried, and depending on the
81               advice.pushUnqualifiedRefname configuration (see git-config(1))
82               suggest what refs/ namespace you may have wanted to push to.
83
84           The object referenced by <src> is used to update the <dst>
85           reference on the remote side. Whether this is allowed depends on
86           where in refs/* the <dst> reference lives as described in detail
87           below, in those sections "update" means any modifications except
88           deletes, which as noted after the next few sections are treated
89           differently.
90
91           The refs/heads/* namespace will only accept commit objects, and
92           updates only if they can be fast-forwarded.
93
94           The refs/tags/* namespace will accept any kind of object (as
95           commits, trees and blobs can be tagged), and any updates to them
96           will be rejected.
97
98           It’s possible to push any type of object to any namespace outside
99           of refs/{tags,heads}/*. In the case of tags and commits, these will
100           be treated as if they were the commits inside refs/heads/* for the
101           purposes of whether the update is allowed.
102
103           I.e. a fast-forward of commits and tags outside refs/{tags,heads}/*
104           is allowed, even in cases where what’s being fast-forwarded is not
105           a commit, but a tag object which happens to point to a new commit
106           which is a fast-forward of the commit the last tag (or commit) it’s
107           replacing. Replacing a tag with an entirely different tag is also
108           allowed, if it points to the same commit, as well as pushing a
109           peeled tag, i.e. pushing the commit that existing tag object points
110           to, or a new tag object which an existing commit points to.
111
112           Tree and blob objects outside of refs/{tags,heads}/* will be
113           treated the same way as if they were inside refs/tags/*, any update
114           of them will be rejected.
115
116           All of the rules described above about what’s not allowed as an
117           update can be overridden by adding an the optional leading + to a
118           refspec (or using --force command line option). The only exception
119           to this is that no amount of forcing will make the refs/heads/*
120           namespace accept a non-commit object. Hooks and configuration can
121           also override or amend these rules, see e.g.
122           receive.denyNonFastForwards in git-config(1) and pre-receive and
123           update in githooks(5).
124
125           Pushing an empty <src> allows you to delete the <dst> ref from the
126           remote repository. Deletions are always accepted without a leading
127           + in the refspec (or --force), except when forbidden by
128           configuration or hooks. See receive.denyDeletes in git-config(1)
129           and pre-receive and update in githooks(5).
130
131           The special refspec : (or +: to allow non-fast-forward updates)
132           directs Git to push "matching" branches: for every branch that
133           exists on the local side, the remote side is updated if a branch of
134           the same name already exists on the remote side.
135
136           tag <tag> means the same as refs/tags/<tag>:refs/tags/<tag>.
137
138       --all
139           Push all branches (i.e. refs under refs/heads/); cannot be used
140           with other <refspec>.
141
142       --prune
143           Remove remote branches that don’t have a local counterpart. For
144           example a remote branch tmp will be removed if a local branch with
145           the same name doesn’t exist any more. This also respects refspecs,
146           e.g.  git push --prune remote refs/heads/*:refs/tmp/* would make
147           sure that remote refs/tmp/foo will be removed if refs/heads/foo
148           doesn’t exist.
149
150       --mirror
151           Instead of naming each ref to push, specifies that all refs under
152           refs/ (which includes but is not limited to refs/heads/,
153           refs/remotes/, and refs/tags/) be mirrored to the remote
154           repository. Newly created local refs will be pushed to the remote
155           end, locally updated refs will be force updated on the remote end,
156           and deleted refs will be removed from the remote end. This is the
157           default if the configuration option remote.<remote>.mirror is set.
158
159       -n, --dry-run
160           Do everything except actually send the updates.
161
162       --porcelain
163           Produce machine-readable output. The output status line for each
164           ref will be tab-separated and sent to stdout instead of stderr. The
165           full symbolic names of the refs will be given.
166
167       -d, --delete
168           All listed refs are deleted from the remote repository. This is the
169           same as prefixing all refs with a colon.
170
171       --tags
172           All refs under refs/tags are pushed, in addition to refspecs
173           explicitly listed on the command line.
174
175       --follow-tags
176           Push all the refs that would be pushed without this option, and
177           also push annotated tags in refs/tags that are missing from the
178           remote but are pointing at commit-ish that are reachable from the
179           refs being pushed. This can also be specified with configuration
180           variable push.followTags. For more information, see push.followTags
181           in git-config(1).
182
183       --[no-]signed, --signed=(true|false|if-asked)
184           GPG-sign the push request to update refs on the receiving side, to
185           allow it to be checked by the hooks and/or be logged. If false or
186           --no-signed, no signing will be attempted. If true or --signed, the
187           push will fail if the server does not support signed pushes. If set
188           to if-asked, sign if and only if the server supports signed pushes.
189           The push will also fail if the actual call to gpg --sign fails. See
190           git-receive-pack(1) for the details on the receiving end.
191
192       --[no-]atomic
193           Use an atomic transaction on the remote side if available. Either
194           all refs are updated, or on error, no refs are updated. If the
195           server does not support atomic pushes the push will fail.
196
197       -o <option>, --push-option=<option>
198           Transmit the given string to the server, which passes them to the
199           pre-receive as well as the post-receive hook. The given string must
200           not contain a NUL or LF character. When multiple
201           --push-option=<option> are given, they are all sent to the other
202           side in the order listed on the command line. When no
203           --push-option=<option> is given from the command line, the values
204           of configuration variable push.pushOption are used instead.
205
206       --receive-pack=<git-receive-pack>, --exec=<git-receive-pack>
207           Path to the git-receive-pack program on the remote end. Sometimes
208           useful when pushing to a remote repository over ssh, and you do not
209           have the program in a directory on the default $PATH.
210
211       --[no-]force-with-lease, --force-with-lease=<refname>,
212       --force-with-lease=<refname>:<expect>
213           Usually, "git push" refuses to update a remote ref that is not an
214           ancestor of the local ref used to overwrite it.
215
216           This option overrides this restriction if the current value of the
217           remote ref is the expected value. "git push" fails otherwise.
218
219           Imagine that you have to rebase what you have already published.
220           You will have to bypass the "must fast-forward" rule in order to
221           replace the history you originally published with the rebased
222           history. If somebody else built on top of your original history
223           while you are rebasing, the tip of the branch at the remote may
224           advance with her commit, and blindly pushing with --force will lose
225           her work.
226
227           This option allows you to say that you expect the history you are
228           updating is what you rebased and want to replace. If the remote ref
229           still points at the commit you specified, you can be sure that no
230           other people did anything to the ref. It is like taking a "lease"
231           on the ref without explicitly locking it, and the remote ref is
232           updated only if the "lease" is still valid.
233
234           --force-with-lease alone, without specifying the details, will
235           protect all remote refs that are going to be updated by requiring
236           their current value to be the same as the remote-tracking branch we
237           have for them.
238
239           --force-with-lease=<refname>, without specifying the expected
240           value, will protect the named ref (alone), if it is going to be
241           updated, by requiring its current value to be the same as the
242           remote-tracking branch we have for it.
243
244           --force-with-lease=<refname>:<expect> will protect the named ref
245           (alone), if it is going to be updated, by requiring its current
246           value to be the same as the specified value <expect> (which is
247           allowed to be different from the remote-tracking branch we have for
248           the refname, or we do not even have to have such a remote-tracking
249           branch when this form is used). If <expect> is the empty string,
250           then the named ref must not already exist.
251
252           Note that all forms other than
253           --force-with-lease=<refname>:<expect> that specifies the expected
254           current value of the ref explicitly are still experimental and
255           their semantics may change as we gain experience with this feature.
256
257           "--no-force-with-lease" will cancel all the previous
258           --force-with-lease on the command line.
259
260           A general note on safety: supplying this option without an expected
261           value, i.e. as --force-with-lease or --force-with-lease=<refname>
262           interacts very badly with anything that implicitly runs git fetch
263           on the remote to be pushed to in the background, e.g.  git fetch
264           origin on your repository in a cronjob.
265
266           The protection it offers over --force is ensuring that subsequent
267           changes your work wasn’t based on aren’t clobbered, but this is
268           trivially defeated if some background process is updating refs in
269           the background. We don’t have anything except the remote tracking
270           info to go by as a heuristic for refs you’re expected to have seen
271           & are willing to clobber.
272
273           If your editor or some other system is running git fetch in the
274           background for you a way to mitigate this is to simply set up
275           another remote:
276
277               git remote add origin-push $(git config remote.origin.url)
278               git fetch origin-push
279
280           Now when the background process runs git fetch origin the
281           references on origin-push won’t be updated, and thus commands like:
282
283               git push --force-with-lease origin-push
284
285           Will fail unless you manually run git fetch origin-push. This
286           method is of course entirely defeated by something that runs git
287           fetch --all, in that case you’d need to either disable it or do
288           something more tedious like:
289
290               git fetch              # update 'master' from remote
291               git tag base master    # mark our base point
292               git rebase -i master   # rewrite some commits
293               git push --force-with-lease=master:base master:master
294
295           I.e. create a base tag for versions of the upstream code that
296           you’ve seen and are willing to overwrite, then rewrite history, and
297           finally force push changes to master if the remote version is still
298           at base, regardless of what your local remotes/origin/master has
299           been updated to in the background.
300
301       -f, --force
302           Usually, the command refuses to update a remote ref that is not an
303           ancestor of the local ref used to overwrite it. Also, when
304           --force-with-lease option is used, the command refuses to update a
305           remote ref whose current value does not match what is expected.
306
307           This flag disables these checks, and can cause the remote
308           repository to lose commits; use it with care.
309
310           Note that --force applies to all the refs that are pushed, hence
311           using it with push.default set to matching or with multiple push
312           destinations configured with remote.*.push may overwrite refs other
313           than the current branch (including local refs that are strictly
314           behind their remote counterpart). To force a push to only one
315           branch, use a + in front of the refspec to push (e.g git push
316           origin +master to force a push to the master branch). See the
317           <refspec>...  section above for details.
318
319       --repo=<repository>
320           This option is equivalent to the <repository> argument. If both are
321           specified, the command-line argument takes precedence.
322
323       -u, --set-upstream
324           For every branch that is up to date or successfully pushed, add
325           upstream (tracking) reference, used by argument-less git-pull(1)
326           and other commands. For more information, see branch.<name>.merge
327           in git-config(1).
328
329       --[no-]thin
330           These options are passed to git-send-pack(1). A thin transfer
331           significantly reduces the amount of sent data when the sender and
332           receiver share many of the same objects in common. The default is
333           --thin.
334
335       -q, --quiet
336           Suppress all output, including the listing of updated refs, unless
337           an error occurs. Progress is not reported to the standard error
338           stream.
339
340       -v, --verbose
341           Run verbosely.
342
343       --progress
344           Progress status is reported on the standard error stream by default
345           when it is attached to a terminal, unless -q is specified. This
346           flag forces progress status even if the standard error stream is
347           not directed to a terminal.
348
349       --no-recurse-submodules, --recurse-submodules=check|on-demand|only|no
350           May be used to make sure all submodule commits used by the
351           revisions to be pushed are available on a remote-tracking branch.
352           If check is used Git will verify that all submodule commits that
353           changed in the revisions to be pushed are available on at least one
354           remote of the submodule. If any commits are missing the push will
355           be aborted and exit with non-zero status. If on-demand is used all
356           submodules that changed in the revisions to be pushed will be
357           pushed. If on-demand was not able to push all necessary revisions
358           it will also be aborted and exit with non-zero status. If only is
359           used all submodules will be recursively pushed while the
360           superproject is left unpushed. A value of no or using
361           --no-recurse-submodules can be used to override the
362           push.recurseSubmodules configuration variable when no submodule
363           recursion is required.
364
365       --[no-]verify
366           Toggle the pre-push hook (see githooks(5)). The default is
367           --verify, giving the hook a chance to prevent the push. With
368           --no-verify, the hook is bypassed completely.
369
370       -4, --ipv4
371           Use IPv4 addresses only, ignoring IPv6 addresses.
372
373       -6, --ipv6
374           Use IPv6 addresses only, ignoring IPv4 addresses.
375

GIT URLS

377       In general, URLs contain information about the transport protocol, the
378       address of the remote server, and the path to the repository. Depending
379       on the transport protocol, some of this information may be absent.
380
381       Git supports ssh, git, http, and https protocols (in addition, ftp, and
382       ftps can be used for fetching, but this is inefficient and deprecated;
383       do not use it).
384
385       The native transport (i.e. git:// URL) does no authentication and
386       should be used with caution on unsecured networks.
387
388       The following syntaxes may be used with them:
389
390       ·   ssh://[user@]host.xz[:port]/path/to/repo.git/
391
392       ·   git://host.xz[:port]/path/to/repo.git/
393
394       ·   http[s]://host.xz[:port]/path/to/repo.git/
395
396       ·   ftp[s]://host.xz[:port]/path/to/repo.git/
397
398       An alternative scp-like syntax may also be used with the ssh protocol:
399
400       ·   [user@]host.xz:path/to/repo.git/
401
402       This syntax is only recognized if there are no slashes before the first
403       colon. This helps differentiate a local path that contains a colon. For
404       example the local path foo:bar could be specified as an absolute path
405       or ./foo:bar to avoid being misinterpreted as an ssh url.
406
407       The ssh and git protocols additionally support ~username expansion:
408
409       ·   ssh://[user@]host.xz[:port]/~[user]/path/to/repo.git/
410
411       ·   git://host.xz[:port]/~[user]/path/to/repo.git/
412
413       ·   [user@]host.xz:/~[user]/path/to/repo.git/
414
415       For local repositories, also supported by Git natively, the following
416       syntaxes may be used:
417
418       ·   /path/to/repo.git/
419
420       ·   file:///path/to/repo.git/
421
422       These two syntaxes are mostly equivalent, except when cloning, when the
423       former implies --local option. See git-clone(1) for details.
424
425       git clone, git fetch and git pull, but not git push, will also accept a
426       suitable bundle file. See git-bundle(1).
427
428       When Git doesn’t know how to handle a certain transport protocol, it
429       attempts to use the remote-<transport> remote helper, if one exists. To
430       explicitly request a remote helper, the following syntax may be used:
431
432       ·   <transport>::<address>
433
434       where <address> may be a path, a server and path, or an arbitrary
435       URL-like string recognized by the specific remote helper being invoked.
436       See gitremote-helpers(7) for details.
437
438       If there are a large number of similarly-named remote repositories and
439       you want to use a different format for them (such that the URLs you use
440       will be rewritten into URLs that work), you can create a configuration
441       section of the form:
442
443                   [url "<actual url base>"]
444                           insteadOf = <other url base>
445
446       For example, with this:
447
448                   [url "git://git.host.xz/"]
449                           insteadOf = host.xz:/path/to/
450                           insteadOf = work:
451
452       a URL like "work:repo.git" or like "host.xz:/path/to/repo.git" will be
453       rewritten in any context that takes a URL to be
454       "git://git.host.xz/repo.git".
455
456       If you want to rewrite URLs for push only, you can create a
457       configuration section of the form:
458
459                   [url "<actual url base>"]
460                           pushInsteadOf = <other url base>
461
462       For example, with this:
463
464                   [url "ssh://example.org/"]
465                           pushInsteadOf = git://example.org/
466
467       a URL like "git://example.org/path/to/repo.git" will be rewritten to
468       "ssh://example.org/path/to/repo.git" for pushes, but pulls will still
469       use the original URL.
470

REMOTES

472       The name of one of the following can be used instead of a URL as
473       <repository> argument:
474
475       ·   a remote in the Git configuration file: $GIT_DIR/config,
476
477       ·   a file in the $GIT_DIR/remotes directory, or
478
479       ·   a file in the $GIT_DIR/branches directory.
480
481       All of these also allow you to omit the refspec from the command line
482       because they each contain a refspec which git will use by default.
483
484   Named remote in configuration file
485       You can choose to provide the name of a remote which you had previously
486       configured using git-remote(1), git-config(1) or even by a manual edit
487       to the $GIT_DIR/config file. The URL of this remote will be used to
488       access the repository. The refspec of this remote will be used by
489       default when you do not provide a refspec on the command line. The
490       entry in the config file would appear like this:
491
492                   [remote "<name>"]
493                           url = <url>
494                           pushurl = <pushurl>
495                           push = <refspec>
496                           fetch = <refspec>
497
498       The <pushurl> is used for pushes only. It is optional and defaults to
499       <url>.
500
501   Named file in $GIT_DIR/remotes
502       You can choose to provide the name of a file in $GIT_DIR/remotes. The
503       URL in this file will be used to access the repository. The refspec in
504       this file will be used as default when you do not provide a refspec on
505       the command line. This file should have the following format:
506
507                   URL: one of the above URL format
508                   Push: <refspec>
509                   Pull: <refspec>
510
511       Push: lines are used by git push and Pull: lines are used by git pull
512       and git fetch. Multiple Push: and Pull: lines may be specified for
513       additional branch mappings.
514
515   Named file in $GIT_DIR/branches
516       You can choose to provide the name of a file in $GIT_DIR/branches. The
517       URL in this file will be used to access the repository. This file
518       should have the following format:
519
520                   <url>#<head>
521
522       <url> is required; #<head> is optional.
523
524       Depending on the operation, git will use one of the following refspecs,
525       if you don’t provide one on the command line. <branch> is the name of
526       this file in $GIT_DIR/branches and <head> defaults to master.
527
528       git fetch uses:
529
530                   refs/heads/<head>:refs/heads/<branch>
531
532       git push uses:
533
534                   HEAD:refs/heads/<head>
535

OUTPUT

537       The output of "git push" depends on the transport method used; this
538       section describes the output when pushing over the Git protocol (either
539       locally or via ssh).
540
541       The status of the push is output in tabular form, with each line
542       representing the status of a single ref. Each line is of the form:
543
544            <flag> <summary> <from> -> <to> (<reason>)
545
546       If --porcelain is used, then each line of the output is of the form:
547
548            <flag> \t <from>:<to> \t <summary> (<reason>)
549
550       The status of up-to-date refs is shown only if --porcelain or --verbose
551       option is used.
552
553       flag
554           A single character indicating the status of the ref:
555
556           (space)
557               for a successfully pushed fast-forward;
558
559           +
560               for a successful forced update;
561
562           -
563               for a successfully deleted ref;
564
565           *
566               for a successfully pushed new ref;
567
568           !
569               for a ref that was rejected or failed to push; and
570
571           =
572               for a ref that was up to date and did not need pushing.
573
574       summary
575           For a successfully pushed ref, the summary shows the old and new
576           values of the ref in a form suitable for using as an argument to
577           git log (this is <old>..<new> in most cases, and <old>...<new> for
578           forced non-fast-forward updates).
579
580           For a failed update, more details are given:
581
582           rejected
583               Git did not try to send the ref at all, typically because it is
584               not a fast-forward and you did not force the update.
585
586           remote rejected
587               The remote end refused the update. Usually caused by a hook on
588               the remote side, or because the remote repository has one of
589               the following safety options in effect:
590               receive.denyCurrentBranch (for pushes to the checked out
591               branch), receive.denyNonFastForwards (for forced
592               non-fast-forward updates), receive.denyDeletes or
593               receive.denyDeleteCurrent. See git-config(1).
594
595           remote failure
596               The remote end did not report the successful update of the ref,
597               perhaps because of a temporary error on the remote side, a
598               break in the network connection, or other transient error.
599
600       from
601           The name of the local ref being pushed, minus its refs/<type>/
602           prefix. In the case of deletion, the name of the local ref is
603           omitted.
604
605       to
606           The name of the remote ref being updated, minus its refs/<type>/
607           prefix.
608
609       reason
610           A human-readable explanation. In the case of successfully pushed
611           refs, no explanation is needed. For a failed ref, the reason for
612           failure is described.
613

NOTE ABOUT FAST-FORWARDS

615       When an update changes a branch (or more in general, a ref) that used
616       to point at commit A to point at another commit B, it is called a
617       fast-forward update if and only if B is a descendant of A.
618
619       In a fast-forward update from A to B, the set of commits that the
620       original commit A built on top of is a subset of the commits the new
621       commit B builds on top of. Hence, it does not lose any history.
622
623       In contrast, a non-fast-forward update will lose history. For example,
624       suppose you and somebody else started at the same commit X, and you
625       built a history leading to commit B while the other person built a
626       history leading to commit A. The history looks like this:
627
628                 B
629                /
630            ---X---A
631
632       Further suppose that the other person already pushed changes leading to
633       A back to the original repository from which you two obtained the
634       original commit X.
635
636       The push done by the other person updated the branch that used to point
637       at commit X to point at commit A. It is a fast-forward.
638
639       But if you try to push, you will attempt to update the branch (that now
640       points at A) with commit B. This does not fast-forward. If you did so,
641       the changes introduced by commit A will be lost, because everybody will
642       now start building on top of B.
643
644       The command by default does not allow an update that is not a
645       fast-forward to prevent such loss of history.
646
647       If you do not want to lose your work (history from X to B) or the work
648       by the other person (history from X to A), you would need to first
649       fetch the history from the repository, create a history that contains
650       changes done by both parties, and push the result back.
651
652       You can perform "git pull", resolve potential conflicts, and "git push"
653       the result. A "git pull" will create a merge commit C between commits A
654       and B.
655
656                 B---C
657                /   /
658            ---X---A
659
660       Updating A with the resulting merge commit will fast-forward and your
661       push will be accepted.
662
663       Alternatively, you can rebase your change between X and B on top of A,
664       with "git pull --rebase", and push the result back. The rebase will
665       create a new commit D that builds the change between X and B on top of
666       A.
667
668                 B   D
669                /   /
670            ---X---A
671
672       Again, updating A with this commit will fast-forward and your push will
673       be accepted.
674
675       There is another common situation where you may encounter
676       non-fast-forward rejection when you try to push, and it is possible
677       even when you are pushing into a repository nobody else pushes into.
678       After you push commit A yourself (in the first picture in this
679       section), replace it with "git commit --amend" to produce commit B, and
680       you try to push it out, because forgot that you have pushed A out
681       already. In such a case, and only if you are certain that nobody in the
682       meantime fetched your earlier commit A (and started building on top of
683       it), you can run "git push --force" to overwrite it. In other words,
684       "git push --force" is a method reserved for a case where you do mean to
685       lose history.
686

EXAMPLES

688       git push
689           Works like git push <remote>, where <remote> is the current
690           branch’s remote (or origin, if no remote is configured for the
691           current branch).
692
693       git push origin
694           Without additional configuration, pushes the current branch to the
695           configured upstream (remote.origin.merge configuration variable) if
696           it has the same name as the current branch, and errors out without
697           pushing otherwise.
698
699           The default behavior of this command when no <refspec> is given can
700           be configured by setting the push option of the remote, or the
701           push.default configuration variable.
702
703           For example, to default to pushing only the current branch to
704           origin use git config remote.origin.push HEAD. Any valid <refspec>
705           (like the ones in the examples below) can be configured as the
706           default for git push origin.
707
708       git push origin :
709           Push "matching" branches to origin. See <refspec> in the OPTIONS
710           section above for a description of "matching" branches.
711
712       git push origin master
713           Find a ref that matches master in the source repository (most
714           likely, it would find refs/heads/master), and update the same ref
715           (e.g.  refs/heads/master) in origin repository with it. If master
716           did not exist remotely, it would be created.
717
718       git push origin HEAD
719           A handy way to push the current branch to the same name on the
720           remote.
721
722       git push mothership master:satellite/master dev:satellite/dev
723           Use the source ref that matches master (e.g.  refs/heads/master) to
724           update the ref that matches satellite/master (most probably
725           refs/remotes/satellite/master) in the mothership repository; do the
726           same for dev and satellite/dev.
727
728           See the section describing <refspec>...  above for a discussion of
729           the matching semantics.
730
731           This is to emulate git fetch run on the mothership using git push
732           that is run in the opposite direction in order to integrate the
733           work done on satellite, and is often necessary when you can only
734           make connection in one way (i.e. satellite can ssh into mothership
735           but mothership cannot initiate connection to satellite because the
736           latter is behind a firewall or does not run sshd).
737
738           After running this git push on the satellite machine, you would ssh
739           into the mothership and run git merge there to complete the
740           emulation of git pull that were run on mothership to pull changes
741           made on satellite.
742
743       git push origin HEAD:master
744           Push the current branch to the remote ref matching master in the
745           origin repository. This form is convenient to push the current
746           branch without thinking about its local name.
747
748       git push origin master:refs/heads/experimental
749           Create the branch experimental in the origin repository by copying
750           the current master branch. This form is only needed to create a new
751           branch or tag in the remote repository when the local name and the
752           remote name are different; otherwise, the ref name on its own will
753           work.
754
755       git push origin :experimental
756           Find a ref that matches experimental in the origin repository (e.g.
757           refs/heads/experimental), and delete it.
758
759       git push origin +dev:master
760           Update the origin repository’s master branch with the dev branch,
761           allowing non-fast-forward updates.  This can leave unreferenced
762           commits dangling in the origin repository.  Consider the following
763           situation, where a fast-forward is not possible:
764
765                           o---o---o---A---B  origin/master
766                                    \
767                                     X---Y---Z  dev
768
769           The above command would change the origin repository to
770
771                                     A---B  (unnamed branch)
772                                    /
773                           o---o---o---X---Y---Z  master
774
775           Commits A and B would no longer belong to a branch with a symbolic
776           name, and so would be unreachable. As such, these commits would be
777           removed by a git gc command on the origin repository.
778

SECURITY

780       The fetch and push protocols are not designed to prevent one side from
781       stealing data from the other repository that was not intended to be
782       shared. If you have private data that you need to protect from a
783       malicious peer, your best option is to store it in another repository.
784       This applies to both clients and servers. In particular, namespaces on
785       a server are not effective for read access control; you should only
786       grant read access to a namespace to clients that you would trust with
787       read access to the entire repository.
788
789       The known attack vectors are as follows:
790
791        1. The victim sends "have" lines advertising the IDs of objects it has
792           that are not explicitly intended to be shared but can be used to
793           optimize the transfer if the peer also has them. The attacker
794           chooses an object ID X to steal and sends a ref to X, but isn’t
795           required to send the content of X because the victim already has
796           it. Now the victim believes that the attacker has X, and it sends
797           the content of X back to the attacker later. (This attack is most
798           straightforward for a client to perform on a server, by creating a
799           ref to X in the namespace the client has access to and then
800           fetching it. The most likely way for a server to perform it on a
801           client is to "merge" X into a public branch and hope that the user
802           does additional work on this branch and pushes it back to the
803           server without noticing the merge.)
804
805        2. As in #1, the attacker chooses an object ID X to steal. The victim
806           sends an object Y that the attacker already has, and the attacker
807           falsely claims to have X and not Y, so the victim sends Y as a
808           delta against X. The delta reveals regions of X that are similar to
809           Y to the attacker.
810

GIT

812       Part of the git(1) suite
813
814
815
816Git 2.26.2                        2020-04-20                       GIT-PUSH(1)
Impressum