The push() method is generic. It only expects the this value to have a length property and integer-keyed properties. Although strings are also array-like, this method is not suitable to be applied on them, as strings are immutable.
The push() method reads the length property of this. It then sets each index of this starting at length with the arguments passed to push(). Finally, it sets the length to the previous length plus the number of pushed elements.
When the command line does not specify where to push with the argument, branch.*.remote configuration for thecurrent branch is consulted to determine where to push. If theconfiguration is missing, it defaults to origin.
When the command line does not specify what to push with ...arguments or --all, --mirror, --tags options, the command findsthe default by consulting remote.*.push configuration,and if it is not found, honors push.default configuration to decidewhat to push (See git-config[1] for the meaning of push.default).
When neither the command-line nor the configuration specifies what topush, the default behavior is used, which corresponds to the simplevalue for push.default: the current branch is pushed to thecorresponding upstream branch, but as a safety measure, the push isaborted if the upstream branch does not have the same name as thelocal one.
Other ambiguity resolutions might be added in the future, but fornow any other cases will error out with an error indicating what wetried, and depending on the advice.pushUnqualifiedRefnameconfiguration (see git-config[1]) suggest what refs/namespace you may have wanted to push to.
The object referenced by is used to update the referenceon the remote side. Whether this is allowed depends on where inrefs/* the reference lives as described in detail below, inthose sections "update" means any modifications except deletes, whichas noted after the next few sections are treated differently.
Pushing an empty allows you to delete the ref from theremote repository. Deletions are always accepted without a leading +in the refspec (or --force), except when forbidden by configurationor hooks. See receive.denyDeletes in git-config[1] andpre-receive and update in githooks[5].
The special refspec : (or +: to allow non-fast-forward updates)directs Git to push "matching" branches: for every branch that exists onthe local side, the remote side is updated if a branch of the same namealready exists on the remote side.
Instead of naming each ref to push, specifies that allrefs under refs/ (which includes but is notlimited to refs/heads/, refs/remotes/, and refs/tags/)be mirrored to the remote repository. Newly created localrefs will be pushed to the remote end, locally updated refswill be force updated on the remote end, and deleted refswill be removed from the remote end. This is the defaultif the configuration option remote..mirror isset.
Push all the refs that would be pushed without this option,and also push annotated tags in refs/tags that are missingfrom the remote but are pointing at commit-ish that arereachable from the refs being pushed. This can also be specifiedwith configuration variable push.followTags. For moreinformation, see push.followTags in git-config[1].
GPG-sign the push request to update refs on the receivingside, to allow it to be checked by the hooks and/or belogged. If false or --no-signed, no signing will beattempted. If true or --signed, the push will fail if theserver does not support signed pushes. If set to if-asked,sign if and only if the server supports signed pushes. The pushwill also fail if the actual call to gpg --sign fails. Seegit-receive-pack[1] for the details on the receiving end.
Transmit the given string to the server, which passes them tothe pre-receive as well as the post-receive hook. The given stringmust not contain a NUL or LF character.When multiple --push-option= are given, they areall sent to the other side in the order listed on thecommand line.When no --push-option= is given from the commandline, the values of configuration variable push.pushOptionare used instead.
Imagine that you have to rebase what you have already published.You will have to bypass the "must fast-forward" rule in order toreplace the history you originally published with the rebased history.If somebody else built on top of your original history while you arerebasing, the tip of the branch at the remote may advance with theircommit, and blindly pushing with --force will lose their work.
This option allows you to say that you expect the history you areupdating is what you rebased and want to replace. If the remote refstill points at the commit you specified, you can be sure that noother people did anything to the ref. It is like taking a "lease" onthe ref without explicitly locking it, and the remote ref is updatedonly if the "lease" is still valid.
--force-with-lease alone, without specifying the details, will protectall remote refs that are going to be updated by requiring theircurrent value to be the same as the remote-tracking branch we havefor them.
--force-with-lease=, without specifying the expected value, willprotect the named ref (alone), if it is going to be updated, byrequiring its current value to be the same as the remote-trackingbranch we have for it.
--force-with-lease=: will protect the named ref (alone),if it is going to be updated, by requiring its current value to bethe same as the specified value (which is allowed to bedifferent from the remote-tracking branch we have for the refname,or we do not even have to have such a remote-tracking branch whenthis form is used). If is the empty string, then the named refmust not already exist.
Note that all forms other than --force-with-lease=:that specifies the expected current value of the ref explicitly arestill experimental and their semantics may change as we gain experiencewith this feature.
A general note on safety: supplying this option without an expectedvalue, i.e. as --force-with-lease or --force-with-lease=interacts very badly with anything that implicitly runs git fetch onthe remote to be pushed to in the background, e.g. git fetch originon your repository in a cronjob.
Alternatively, specifying --force-if-includes as an ancillary optionalong with --force-with-lease[=] (i.e., without saying whatexact commit the ref on the remote side must be pointing at, or whichrefs on the remote side are being protected) at the time of "push" willverify if updates from the remote-tracking refs that may have beenimplicitly updated in the background are integrated locally beforeallowing a forced update.
Usually, the command refuses to update a remote ref that isnot an ancestor of the local ref used to overwrite it.Also, when --force-with-lease option is used, the command refusesto update a remote ref whose current value does not matchwhat is expected.
Note that --force applies to all the refs that are pushed, henceusing it with push.default set to matching or with multiple pushdestinations configured with remote.*.push may overwrite refsother than the current branch (including local refs that arestrictly behind their remote counterpart). To force a push to onlyone branch, use a + in front of the refspec to push (e.g git pushorigin +master to force a push to the master branch). See the... section above for details.
This option enables a check that verifies if the tip of theremote-tracking ref is reachable from one of the "reflog" entries ofthe local branch based in it for a rewrite. The check ensures that anyupdates from the remote have been incorporated locally by rejecting theforced update if that is not the case.
For every branch that is up to date or successfully pushed, addupstream (tracking) reference, used by argument-lessgit-pull[1] and other commands. For more information,see branch..merge in git-config[1].
Progress status is reported on the standard error streamby default when it is attached to a terminal, unless -qis specified. This flag forces progress status even if thestandard error stream is not directed to a terminal.
May be used to make sure all submodule commits used by therevisions to be pushed are available on a remote-tracking branch.If check is used Git will verify that all submodule commits thatchanged in the revisions to be pushed are available on at least oneremote of the submodule. If any commits are missing the push willbe aborted and exit with non-zero status. If on-demand is usedall submodules that changed in the revisions to be pushed will bepushed. If on-demand was not able to push all necessary revisions it willalso be aborted and exit with non-zero status. If only is used allsubmodules will be pushed while the superproject is leftunpushed. A value of no or using --no-recurse-submodules can be usedto override the push.recurseSubmodules configuration variable when nosubmodule recursion is required.
When using on-demand or only, if a submodule has a"push.recurseSubmodules=on-demand,only" or "submodule.recurse" configuration,further recursion will occur. In this case, "only" is treated as "on-demand".
In general, URLs contain information about the transport protocol, theaddress of the remote server, and the path to the repository.Depending on the transport protocol, some of this information may beabsent.
This syntax is only recognized if there are no slashes before thefirst colon. This helps differentiate a local path that contains acolon. For example the local path foo:bar could be specified as anabsolute path or ./foo:bar to avoid being misinterpreted as an sshurl.
If there are a large number of similarly-named remote repositories andyou want to use a different format for them (such that the URLs youuse will be rewritten into URLs that work), you can create aconfiguration section of the form:
4a15465005