1GIT-PUSH(1) Git Manual GIT-PUSH(1)
2
3
4
6 git-push - Update remote refs along with associated objects
7
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
16
18 Updates remote refs using local refs, while sending objects necessary
19 to complete the given refs.
20
21 You can make interesting things happen to a repository every time you
22 push into it, by setting up hooks there. See documentation for git-
23 receive-pack(1).
24
25 When the command line does not specify where to push with the
26 <repository> argument, branch.*.remote configuration for the current
27 branch is consulted to determine where to push. If the configuration is
28 missing, it defaults to origin.
29
30 When the command line does not specify what to push with <refspec>...
31 arguments or --all, --mirror, --tags options, the command finds the
32 default <refspec> by consulting remote.*.push configuration, and if it
33 is not found, honors push.default configuration to decide what to push
34 (See git-config(1) for the meaning of push.default).
35
36 When neither the command-line nor the configuration specify what to
37 push, the default behavior is used, which corresponds to the simple
38 value for push.default: the current branch is pushed to the
39 corresponding upstream branch, but as a safety measure, the push is
40 aborted if the upstream branch does not have the same name as the local
41 one.
42
44 <repository>
45 The "remote" repository that is destination of a push operation.
46 This parameter can be either a URL (see the section GIT URLS below)
47 or the name of a remote (see the section REMOTES below).
48
49 <refspec>...
50 Specify what destination ref to update with what source object. The
51 format of a <refspec> parameter is an optional plus +, followed by
52 the source object <src>, followed by a colon :, followed by the
53 destination ref <dst>.
54
55 The <src> is often the name of the branch you would want to push,
56 but it can be any arbitrary "SHA-1 expression", such as master~4 or
57 HEAD (see gitrevisions(7)).
58
59 The <dst> tells which ref on the remote side is updated with this
60 push. Arbitrary expressions cannot be used here, an actual ref must
61 be named. If git push [<repository>] without any <refspec> argument
62 is set to update some ref at the destination with <src> with
63 remote.<repository>.push configuration variable, :<dst> part can be
64 omitted—such a push will update a ref that <src> normally updates
65 without any <refspec> on the command line. Otherwise, missing
66 :<dst> means to update the same ref as the <src>.
67
68 The object referenced by <src> is used to update the <dst>
69 reference on the remote side. Whether this is allowed depends on
70 where in refs/* the <dst> reference lives as described in detail
71 below, in those sections "update" means any modifications except
72 deletes, which as noted after the next few sections are treated
73 differently.
74
75 The refs/heads/* namespace will only accept commit objects, and
76 updates only if they can be fast-forwarded.
77
78 The refs/tags/* namespace will accept any kind of object (as
79 commits, trees and blobs can be tagged), and any updates to them
80 will be rejected.
81
82 It’s possible to push any type of object to any namespace outside
83 of refs/{tags,heads}/*. In the case of tags and commits, these will
84 be treated as if they were the commits inside refs/heads/* for the
85 purposes of whether the update is allowed.
86
87 I.e. a fast-forward of commits and tags outside refs/{tags,heads}/*
88 is allowed, even in cases where what’s being fast-forwarded is not
89 a commit, but a tag object which happens to point to a new commit
90 which is a fast-forward of the commit the last tag (or commit) it’s
91 replacing. Replacing a tag with an entirely different tag is also
92 allowed, if it points to the same commit, as well as pushing a
93 peeled tag, i.e. pushing the commit that existing tag object points
94 to, or a new tag object which an existing commit points to.
95
96 Tree and blob objects outside of refs/{tags,heads}/* will be
97 treated the same way as if they were inside refs/tags/*, any update
98 of them will be rejected.
99
100 All of the rules described above about what’s not allowed as an
101 update can be overridden by adding an the optional leading + to a
102 refspec (or using --force command line option). The only exception
103 to this is that no amount of forcing will make the refs/heads/*
104 namespace accept a non-commit object. Hooks and configuration can
105 also override or amend these rules, see e.g.
106 receive.denyNonFastForwards in git-config(1) and pre-receive and
107 update in githooks(5).
108
109 Pushing an empty <src> allows you to delete the <dst> ref from the
110 remote repository. Deletions are always accepted without a leading
111 + in the refspec (or --force), except when forbidden by
112 configuration or hooks. See receive.denyDeletes in git-config(1)
113 and pre-receive and update in githooks(5).
114
115 The special refspec : (or +: to allow non-fast-forward updates)
116 directs Git to push "matching" branches: for every branch that
117 exists on the local side, the remote side is updated if a branch of
118 the same name already exists on the remote side.
119
120 tag <tag> means the same as refs/tags/<tag>:refs/tags/<tag>.
121
122 --all
123 Push all branches (i.e. refs under refs/heads/); cannot be used
124 with other <refspec>.
125
126 --prune
127 Remove remote branches that don’t have a local counterpart. For
128 example a remote branch tmp will be removed if a local branch with
129 the same name doesn’t exist any more. This also respects refspecs,
130 e.g. git push --prune remote refs/heads/*:refs/tmp/* would make
131 sure that remote refs/tmp/foo will be removed if refs/heads/foo
132 doesn’t exist.
133
134 --mirror
135 Instead of naming each ref to push, specifies that all refs under
136 refs/ (which includes but is not limited to refs/heads/,
137 refs/remotes/, and refs/tags/) be mirrored to the remote
138 repository. Newly created local refs will be pushed to the remote
139 end, locally updated refs will be force updated on the remote end,
140 and deleted refs will be removed from the remote end. This is the
141 default if the configuration option remote.<remote>.mirror is set.
142
143 -n, --dry-run
144 Do everything except actually send the updates.
145
146 --porcelain
147 Produce machine-readable output. The output status line for each
148 ref will be tab-separated and sent to stdout instead of stderr. The
149 full symbolic names of the refs will be given.
150
151 -d, --delete
152 All listed refs are deleted from the remote repository. This is the
153 same as prefixing all refs with a colon.
154
155 --tags
156 All refs under refs/tags are pushed, in addition to refspecs
157 explicitly listed on the command line.
158
159 --follow-tags
160 Push all the refs that would be pushed without this option, and
161 also push annotated tags in refs/tags that are missing from the
162 remote but are pointing at commit-ish that are reachable from the
163 refs being pushed. This can also be specified with configuration
164 variable push.followTags. For more information, see push.followTags
165 in git-config(1).
166
167 --[no-]signed, --signed=(true|false|if-asked)
168 GPG-sign the push request to update refs on the receiving side, to
169 allow it to be checked by the hooks and/or be logged. If false or
170 --no-signed, no signing will be attempted. If true or --signed, the
171 push will fail if the server does not support signed pushes. If set
172 to if-asked, sign if and only if the server supports signed pushes.
173 The push will also fail if the actual call to gpg --sign fails. See
174 git-receive-pack(1) for the details on the receiving end.
175
176 --[no-]atomic
177 Use an atomic transaction on the remote side if available. Either
178 all refs are updated, or on error, no refs are updated. If the
179 server does not support atomic pushes the push will fail.
180
181 -o <option>, --push-option=<option>
182 Transmit the given string to the server, which passes them to the
183 pre-receive as well as the post-receive hook. The given string must
184 not contain a NUL or LF character. When multiple
185 --push-option=<option> are given, they are all sent to the other
186 side in the order listed on the command line. When no
187 --push-option=<option> is given from the command line, the values
188 of configuration variable push.pushOption are used instead.
189
190 --receive-pack=<git-receive-pack>, --exec=<git-receive-pack>
191 Path to the git-receive-pack program on the remote end. Sometimes
192 useful when pushing to a remote repository over ssh, and you do not
193 have the program in a directory on the default $PATH.
194
195 --[no-]force-with-lease, --force-with-lease=<refname>,
196 --force-with-lease=<refname>:<expect>
197 Usually, "git push" refuses to update a remote ref that is not an
198 ancestor of the local ref used to overwrite it.
199
200 This option overrides this restriction if the current value of the
201 remote ref is the expected value. "git push" fails otherwise.
202
203 Imagine that you have to rebase what you have already published.
204 You will have to bypass the "must fast-forward" rule in order to
205 replace the history you originally published with the rebased
206 history. If somebody else built on top of your original history
207 while you are rebasing, the tip of the branch at the remote may
208 advance with her commit, and blindly pushing with --force will lose
209 her work.
210
211 This option allows you to say that you expect the history you are
212 updating is what you rebased and want to replace. If the remote ref
213 still points at the commit you specified, you can be sure that no
214 other people did anything to the ref. It is like taking a "lease"
215 on the ref without explicitly locking it, and the remote ref is
216 updated only if the "lease" is still valid.
217
218 --force-with-lease alone, without specifying the details, will
219 protect all remote refs that are going to be updated by requiring
220 their current value to be the same as the remote-tracking branch we
221 have for them.
222
223 --force-with-lease=<refname>, without specifying the expected
224 value, will protect the named ref (alone), if it is going to be
225 updated, by requiring its current value to be the same as the
226 remote-tracking branch we have for it.
227
228 --force-with-lease=<refname>:<expect> will protect the named ref
229 (alone), if it is going to be updated, by requiring its current
230 value to be the same as the specified value <expect> (which is
231 allowed to be different from the remote-tracking branch we have for
232 the refname, or we do not even have to have such a remote-tracking
233 branch when this form is used). If <expect> is the empty string,
234 then the named ref must not already exist.
235
236 Note that all forms other than
237 --force-with-lease=<refname>:<expect> that specifies the expected
238 current value of the ref explicitly are still experimental and
239 their semantics may change as we gain experience with this feature.
240
241 "--no-force-with-lease" will cancel all the previous
242 --force-with-lease on the command line.
243
244 A general note on safety: supplying this option without an expected
245 value, i.e. as --force-with-lease or --force-with-lease=<refname>
246 interacts very badly with anything that implicitly runs git fetch
247 on the remote to be pushed to in the background, e.g. git fetch
248 origin on your repository in a cronjob.
249
250 The protection it offers over --force is ensuring that subsequent
251 changes your work wasn’t based on aren’t clobbered, but this is
252 trivially defeated if some background process is updating refs in
253 the background. We don’t have anything except the remote tracking
254 info to go by as a heuristic for refs you’re expected to have seen
255 & are willing to clobber.
256
257 If your editor or some other system is running git fetch in the
258 background for you a way to mitigate this is to simply set up
259 another remote:
260
261 git remote add origin-push $(git config remote.origin.url)
262 git fetch origin-push
263
264 Now when the background process runs git fetch origin the
265 references on origin-push won’t be updated, and thus commands like:
266
267 git push --force-with-lease origin-push
268
269 Will fail unless you manually run git fetch origin-push. This
270 method is of course entirely defeated by something that runs git
271 fetch --all, in that case you’d need to either disable it or do
272 something more tedious like:
273
274 git fetch # update 'master' from remote
275 git tag base master # mark our base point
276 git rebase -i master # rewrite some commits
277 git push --force-with-lease=master:base master:master
278
279 I.e. create a base tag for versions of the upstream code that
280 you’ve seen and are willing to overwrite, then rewrite history, and
281 finally force push changes to master if the remote version is still
282 at base, regardless of what your local remotes/origin/master has
283 been updated to in the background.
284
285 -f, --force
286 Usually, the command refuses to update a remote ref that is not an
287 ancestor of the local ref used to overwrite it. Also, when
288 --force-with-lease option is used, the command refuses to update a
289 remote ref whose current value does not match what is expected.
290
291 This flag disables these checks, and can cause the remote
292 repository to lose commits; use it with care.
293
294 Note that --force applies to all the refs that are pushed, hence
295 using it with push.default set to matching or with multiple push
296 destinations configured with remote.*.push may overwrite refs other
297 than the current branch (including local refs that are strictly
298 behind their remote counterpart). To force a push to only one
299 branch, use a + in front of the refspec to push (e.g git push
300 origin +master to force a push to the master branch). See the
301 <refspec>... section above for details.
302
303 --repo=<repository>
304 This option is equivalent to the <repository> argument. If both are
305 specified, the command-line argument takes precedence.
306
307 -u, --set-upstream
308 For every branch that is up to date or successfully pushed, add
309 upstream (tracking) reference, used by argument-less git-pull(1)
310 and other commands. For more information, see branch.<name>.merge
311 in git-config(1).
312
313 --[no-]thin
314 These options are passed to git-send-pack(1). A thin transfer
315 significantly reduces the amount of sent data when the sender and
316 receiver share many of the same objects in common. The default is
317 --thin.
318
319 -q, --quiet
320 Suppress all output, including the listing of updated refs, unless
321 an error occurs. Progress is not reported to the standard error
322 stream.
323
324 -v, --verbose
325 Run verbosely.
326
327 --progress
328 Progress status is reported on the standard error stream by default
329 when it is attached to a terminal, unless -q is specified. This
330 flag forces progress status even if the standard error stream is
331 not directed to a terminal.
332
333 --no-recurse-submodules, --recurse-submodules=check|on-demand|only|no
334 May be used to make sure all submodule commits used by the
335 revisions to be pushed are available on a remote-tracking branch.
336 If check is used Git will verify that all submodule commits that
337 changed in the revisions to be pushed are available on at least one
338 remote of the submodule. If any commits are missing the push will
339 be aborted and exit with non-zero status. If on-demand is used all
340 submodules that changed in the revisions to be pushed will be
341 pushed. If on-demand was not able to push all necessary revisions
342 it will also be aborted and exit with non-zero status. If only is
343 used all submodules will be recursively pushed while the
344 superproject is left unpushed. A value of no or using
345 --no-recurse-submodules can be used to override the
346 push.recurseSubmodules configuration variable when no submodule
347 recursion is required.
348
349 --[no-]verify
350 Toggle the pre-push hook (see githooks(5)). The default is
351 --verify, giving the hook a chance to prevent the push. With
352 --no-verify, the hook is bypassed completely.
353
354 -4, --ipv4
355 Use IPv4 addresses only, ignoring IPv6 addresses.
356
357 -6, --ipv6
358 Use IPv6 addresses only, ignoring IPv4 addresses.
359
361 In general, URLs contain information about the transport protocol, the
362 address of the remote server, and the path to the repository. Depending
363 on the transport protocol, some of this information may be absent.
364
365 Git supports ssh, git, http, and https protocols (in addition, ftp, and
366 ftps can be used for fetching, but this is inefficient and deprecated;
367 do not use it).
368
369 The native transport (i.e. git:// URL) does no authentication and
370 should be used with caution on unsecured networks.
371
372 The following syntaxes may be used with them:
373
374 · ssh://[user@]host.xz[:port]/path/to/repo.git/
375
376 · git://host.xz[:port]/path/to/repo.git/
377
378 · http[s]://host.xz[:port]/path/to/repo.git/
379
380 · ftp[s]://host.xz[:port]/path/to/repo.git/
381
382 An alternative scp-like syntax may also be used with the ssh protocol:
383
384 · [user@]host.xz:path/to/repo.git/
385
386 This syntax is only recognized if there are no slashes before the first
387 colon. This helps differentiate a local path that contains a colon. For
388 example the local path foo:bar could be specified as an absolute path
389 or ./foo:bar to avoid being misinterpreted as an ssh url.
390
391 The ssh and git protocols additionally support ~username expansion:
392
393 · ssh://[user@]host.xz[:port]/~[user]/path/to/repo.git/
394
395 · git://host.xz[:port]/~[user]/path/to/repo.git/
396
397 · [user@]host.xz:/~[user]/path/to/repo.git/
398
399 For local repositories, also supported by Git natively, the following
400 syntaxes may be used:
401
402 · /path/to/repo.git/
403
404 · file:///path/to/repo.git/
405
406 These two syntaxes are mostly equivalent, except when cloning, when the
407 former implies --local option. See git-clone(1) for details.
408
409 When Git doesn’t know how to handle a certain transport protocol, it
410 attempts to use the remote-<transport> remote helper, if one exists. To
411 explicitly request a remote helper, the following syntax may be used:
412
413 · <transport>::<address>
414
415 where <address> may be a path, a server and path, or an arbitrary
416 URL-like string recognized by the specific remote helper being invoked.
417 See gitremote-helpers(1) for details.
418
419 If there are a large number of similarly-named remote repositories and
420 you want to use a different format for them (such that the URLs you use
421 will be rewritten into URLs that work), you can create a configuration
422 section of the form:
423
424 [url "<actual url base>"]
425 insteadOf = <other url base>
426
427
428 For example, with this:
429
430 [url "git://git.host.xz/"]
431 insteadOf = host.xz:/path/to/
432 insteadOf = work:
433
434
435 a URL like "work:repo.git" or like "host.xz:/path/to/repo.git" will be
436 rewritten in any context that takes a URL to be
437 "git://git.host.xz/repo.git".
438
439 If you want to rewrite URLs for push only, you can create a
440 configuration section of the form:
441
442 [url "<actual url base>"]
443 pushInsteadOf = <other url base>
444
445
446 For example, with this:
447
448 [url "ssh://example.org/"]
449 pushInsteadOf = git://example.org/
450
451
452 a URL like "git://example.org/path/to/repo.git" will be rewritten to
453 "ssh://example.org/path/to/repo.git" for pushes, but pulls will still
454 use the original URL.
455
457 The name of one of the following can be used instead of a URL as
458 <repository> argument:
459
460 · a remote in the Git configuration file: $GIT_DIR/config,
461
462 · a file in the $GIT_DIR/remotes directory, or
463
464 · a file in the $GIT_DIR/branches directory.
465
466 All of these also allow you to omit the refspec from the command line
467 because they each contain a refspec which git will use by default.
468
469 Named remote in configuration file
470 You can choose to provide the name of a remote which you had previously
471 configured using git-remote(1), git-config(1) or even by a manual edit
472 to the $GIT_DIR/config file. The URL of this remote will be used to
473 access the repository. The refspec of this remote will be used by
474 default when you do not provide a refspec on the command line. The
475 entry in the config file would appear like this:
476
477 [remote "<name>"]
478 url = <url>
479 pushurl = <pushurl>
480 push = <refspec>
481 fetch = <refspec>
482
483
484 The <pushurl> is used for pushes only. It is optional and defaults to
485 <url>.
486
487 Named file in $GIT_DIR/remotes
488 You can choose to provide the name of a file in $GIT_DIR/remotes. The
489 URL in this file will be used to access the repository. The refspec in
490 this file will be used as default when you do not provide a refspec on
491 the command line. This file should have the following format:
492
493 URL: one of the above URL format
494 Push: <refspec>
495 Pull: <refspec>
496
497
498 Push: lines are used by git push and Pull: lines are used by git pull
499 and git fetch. Multiple Push: and Pull: lines may be specified for
500 additional branch mappings.
501
502 Named file in $GIT_DIR/branches
503 You can choose to provide the name of a file in $GIT_DIR/branches. The
504 URL in this file will be used to access the repository. This file
505 should have the following format:
506
507 <url>#<head>
508
509
510 <url> is required; #<head> is optional.
511
512 Depending on the operation, git will use one of the following refspecs,
513 if you don’t provide one on the command line. <branch> is the name of
514 this file in $GIT_DIR/branches and <head> defaults to master.
515
516 git fetch uses:
517
518 refs/heads/<head>:refs/heads/<branch>
519
520
521 git push uses:
522
523 HEAD:refs/heads/<head>
524
525
527 The output of "git push" depends on the transport method used; this
528 section describes the output when pushing over the Git protocol (either
529 locally or via ssh).
530
531 The status of the push is output in tabular form, with each line
532 representing the status of a single ref. Each line is of the form:
533
534 <flag> <summary> <from> -> <to> (<reason>)
535
536
537 If --porcelain is used, then each line of the output is of the form:
538
539 <flag> \t <from>:<to> \t <summary> (<reason>)
540
541
542 The status of up-to-date refs is shown only if --porcelain or --verbose
543 option is used.
544
545 flag
546 A single character indicating the status of the ref:
547
548 (space)
549 for a successfully pushed fast-forward;
550
551 +
552 for a successful forced update;
553
554 -
555 for a successfully deleted ref;
556
557 *
558 for a successfully pushed new ref;
559
560 !
561 for a ref that was rejected or failed to push; and
562
563 =
564 for a ref that was up to date and did not need pushing.
565
566 summary
567 For a successfully pushed ref, the summary shows the old and new
568 values of the ref in a form suitable for using as an argument to
569 git log (this is <old>..<new> in most cases, and <old>...<new> for
570 forced non-fast-forward updates).
571
572 For a failed update, more details are given:
573
574 rejected
575 Git did not try to send the ref at all, typically because it is
576 not a fast-forward and you did not force the update.
577
578 remote rejected
579 The remote end refused the update. Usually caused by a hook on
580 the remote side, or because the remote repository has one of
581 the following safety options in effect:
582 receive.denyCurrentBranch (for pushes to the checked out
583 branch), receive.denyNonFastForwards (for forced
584 non-fast-forward updates), receive.denyDeletes or
585 receive.denyDeleteCurrent. See git-config(1).
586
587 remote failure
588 The remote end did not report the successful update of the ref,
589 perhaps because of a temporary error on the remote side, a
590 break in the network connection, or other transient error.
591
592 from
593 The name of the local ref being pushed, minus its refs/<type>/
594 prefix. In the case of deletion, the name of the local ref is
595 omitted.
596
597 to
598 The name of the remote ref being updated, minus its refs/<type>/
599 prefix.
600
601 reason
602 A human-readable explanation. In the case of successfully pushed
603 refs, no explanation is needed. For a failed ref, the reason for
604 failure is described.
605
607 When an update changes a branch (or more in general, a ref) that used
608 to point at commit A to point at another commit B, it is called a
609 fast-forward update if and only if B is a descendant of A.
610
611 In a fast-forward update from A to B, the set of commits that the
612 original commit A built on top of is a subset of the commits the new
613 commit B builds on top of. Hence, it does not lose any history.
614
615 In contrast, a non-fast-forward update will lose history. For example,
616 suppose you and somebody else started at the same commit X, and you
617 built a history leading to commit B while the other person built a
618 history leading to commit A. The history looks like this:
619
620 B
621 /
622 ---X---A
623
624
625 Further suppose that the other person already pushed changes leading to
626 A back to the original repository from which you two obtained the
627 original commit X.
628
629 The push done by the other person updated the branch that used to point
630 at commit X to point at commit A. It is a fast-forward.
631
632 But if you try to push, you will attempt to update the branch (that now
633 points at A) with commit B. This does not fast-forward. If you did so,
634 the changes introduced by commit A will be lost, because everybody will
635 now start building on top of B.
636
637 The command by default does not allow an update that is not a
638 fast-forward to prevent such loss of history.
639
640 If you do not want to lose your work (history from X to B) or the work
641 by the other person (history from X to A), you would need to first
642 fetch the history from the repository, create a history that contains
643 changes done by both parties, and push the result back.
644
645 You can perform "git pull", resolve potential conflicts, and "git push"
646 the result. A "git pull" will create a merge commit C between commits A
647 and B.
648
649 B---C
650 / /
651 ---X---A
652
653
654 Updating A with the resulting merge commit will fast-forward and your
655 push will be accepted.
656
657 Alternatively, you can rebase your change between X and B on top of A,
658 with "git pull --rebase", and push the result back. The rebase will
659 create a new commit D that builds the change between X and B on top of
660 A.
661
662 B D
663 / /
664 ---X---A
665
666
667 Again, updating A with this commit will fast-forward and your push will
668 be accepted.
669
670 There is another common situation where you may encounter
671 non-fast-forward rejection when you try to push, and it is possible
672 even when you are pushing into a repository nobody else pushes into.
673 After you push commit A yourself (in the first picture in this
674 section), replace it with "git commit --amend" to produce commit B, and
675 you try to push it out, because forgot that you have pushed A out
676 already. In such a case, and only if you are certain that nobody in the
677 meantime fetched your earlier commit A (and started building on top of
678 it), you can run "git push --force" to overwrite it. In other words,
679 "git push --force" is a method reserved for a case where you do mean to
680 lose history.
681
683 git push
684 Works like git push <remote>, where <remote> is the current
685 branch’s remote (or origin, if no remote is configured for the
686 current branch).
687
688 git push origin
689 Without additional configuration, pushes the current branch to the
690 configured upstream (remote.origin.merge configuration variable) if
691 it has the same name as the current branch, and errors out without
692 pushing otherwise.
693
694 The default behavior of this command when no <refspec> is given can
695 be configured by setting the push option of the remote, or the
696 push.default configuration variable.
697
698 For example, to default to pushing only the current branch to
699 origin use git config remote.origin.push HEAD. Any valid <refspec>
700 (like the ones in the examples below) can be configured as the
701 default for git push origin.
702
703 git push origin :
704 Push "matching" branches to origin. See <refspec> in the OPTIONS
705 section above for a description of "matching" branches.
706
707 git push origin master
708 Find a ref that matches master in the source repository (most
709 likely, it would find refs/heads/master), and update the same ref
710 (e.g. refs/heads/master) in origin repository with it. If master
711 did not exist remotely, it would be created.
712
713 git push origin HEAD
714 A handy way to push the current branch to the same name on the
715 remote.
716
717 git push mothership master:satellite/master dev:satellite/dev
718 Use the source ref that matches master (e.g. refs/heads/master) to
719 update the ref that matches satellite/master (most probably
720 refs/remotes/satellite/master) in the mothership repository; do the
721 same for dev and satellite/dev.
722
723 This is to emulate git fetch run on the mothership using git push
724 that is run in the opposite direction in order to integrate the
725 work done on satellite, and is often necessary when you can only
726 make connection in one way (i.e. satellite can ssh into mothership
727 but mothership cannot initiate connection to satellite because the
728 latter is behind a firewall or does not run sshd).
729
730 After running this git push on the satellite machine, you would ssh
731 into the mothership and run git merge there to complete the
732 emulation of git pull that were run on mothership to pull changes
733 made on satellite.
734
735 git push origin HEAD:master
736 Push the current branch to the remote ref matching master in the
737 origin repository. This form is convenient to push the current
738 branch without thinking about its local name.
739
740 git push origin master:refs/heads/experimental
741 Create the branch experimental in the origin repository by copying
742 the current master branch. This form is only needed to create a new
743 branch or tag in the remote repository when the local name and the
744 remote name are different; otherwise, the ref name on its own will
745 work.
746
747 git push origin :experimental
748 Find a ref that matches experimental in the origin repository (e.g.
749 refs/heads/experimental), and delete it.
750
751 git push origin +dev:master
752 Update the origin repository’s master branch with the dev branch,
753 allowing non-fast-forward updates. This can leave unreferenced
754 commits dangling in the origin repository. Consider the following
755 situation, where a fast-forward is not possible:
756
757 o---o---o---A---B origin/master
758 \
759 X---Y---Z dev
760
761 The above command would change the origin repository to
762
763 A---B (unnamed branch)
764 /
765 o---o---o---X---Y---Z master
766
767 Commits A and B would no longer belong to a branch with a symbolic
768 name, and so would be unreachable. As such, these commits would be
769 removed by a git gc command on the origin repository.
770
772 The fetch and push protocols are not designed to prevent one side from
773 stealing data from the other repository that was not intended to be
774 shared. If you have private data that you need to protect from a
775 malicious peer, your best option is to store it in another repository.
776 This applies to both clients and servers. In particular, namespaces on
777 a server are not effective for read access control; you should only
778 grant read access to a namespace to clients that you would trust with
779 read access to the entire repository.
780
781 The known attack vectors are as follows:
782
783 1. The victim sends "have" lines advertising the IDs of objects it has
784 that are not explicitly intended to be shared but can be used to
785 optimize the transfer if the peer also has them. The attacker
786 chooses an object ID X to steal and sends a ref to X, but isn’t
787 required to send the content of X because the victim already has
788 it. Now the victim believes that the attacker has X, and it sends
789 the content of X back to the attacker later. (This attack is most
790 straightforward for a client to perform on a server, by creating a
791 ref to X in the namespace the client has access to and then
792 fetching it. The most likely way for a server to perform it on a
793 client is to "merge" X into a public branch and hope that the user
794 does additional work on this branch and pushes it back to the
795 server without noticing the merge.)
796
797 2. As in #1, the attacker chooses an object ID X to steal. The victim
798 sends an object Y that the attacker already has, and the attacker
799 falsely claims to have X and not Y, so the victim sends Y as a
800 delta against X. The delta reveals regions of X that are similar to
801 Y to the attacker.
802
804 Part of the git(1) suite
805
806
807
808Git 2.20.1 12/15/2018 GIT-PUSH(1)