diff options
| author | Junio C Hamano <gitster@pobox.com> | 2025-10-14 12:56:09 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-10-14 12:56:09 -0700 |
| commit | 1003719fb700df37557d6d161e757fabb952e78a (patch) | |
| tree | 23545fc855b6c553216a5d253fea64dd374948fe /Documentation/git-push.adoc | |
| parent | deb58e4fa37a30ce56904b3f51308f3aa81d30a0 (diff) | |
| parent | a72504fe051272227f4097e8d664a9b7d871ec25 (diff) | |
| download | git-1003719fb700df37557d6d161e757fabb952e78a.tar.xz | |
Merge branch 'je/doc-push-upstream'
Documentation updates.
* je/doc-push-upstream:
doc: git-push: add explanation of `git push origin main`
doc: git-push: clarify "what to push"
doc: git-push: clarify "where to push"
doc: add an UPSTREAM BRANCHES section to pull/push/fetch
doc: git-push: clarify intro
Diffstat (limited to 'Documentation/git-push.adoc')
| -rw-r--r-- | Documentation/git-push.adoc | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/Documentation/git-push.adoc b/Documentation/git-push.adoc index cc5cadcdfc..864b0d0467 100644 --- a/Documentation/git-push.adoc +++ b/Documentation/git-push.adoc @@ -19,30 +19,35 @@ SYNOPSIS DESCRIPTION ----------- -Updates remote refs using local refs, while sending objects -necessary to complete the given refs. +Updates one or more branches, tags, or other references in a remote +repository from your local repository, and sends all necessary data +that isn't already on the remote. -You can make interesting things happen to a repository -every time you push into it, by setting up 'hooks' there. See -documentation for linkgit:git-receive-pack[1]. +The simplest way to push is `git push <remote> <branch>`. +`git push origin main` will push the local `main` branch to the `main` +branch on the remote named `origin`. + +The `<repository>` argument defaults to the upstream for the current branch, +or `origin` if there's no configured upstream. -When the command line does not specify where to push with the -`<repository>` argument, `branch.*.remote` configuration for the -current branch is consulted to determine where to push. If the -configuration is missing, it defaults to 'origin'. +To decide which branches, tags, or other refs to push, Git uses +(in order of precedence): -When the command line does not specify what to push with `<refspec>...` -arguments or `--all`, `--mirror`, `--tags` options, the command finds -the default `<refspec>` by consulting `remote.*.push` configuration, -and if it is not found, honors `push.default` configuration to decide -what to push (See linkgit:git-config[1] for the meaning of `push.default`). +1. The `<refspec>` argument(s) (for example `main` in `git push origin main`) + or the `--all`, `--mirror`, or `--tags` options +2. The `remote.*.push` configuration for the repository being pushed to +3. The `push.default` configuration. The default is `push.default=simple`, + which will push to a branch with the same name as the current branch. + See the <<CONFIGURATION,CONFIGURATION>> section below for more on `push.default`. -When neither the command-line nor the configuration specifies what to -push, the default behavior is used, which corresponds to the `simple` -value for `push.default`: the current branch is pushed to the -corresponding upstream branch, but as a safety measure, the push is -aborted if the upstream branch does not have the same name as the -local one. +`git push` may fail if you haven't set an upstream for the current branch, +depending on what `push.default` is set to. +See the <<UPSTREAM-BRANCHES,UPSTREAM BRANCHES>> section below for more +on how to set and use upstreams. + +You can make interesting things happen to a repository +every time you push into it, by setting up 'hooks' there. See +documentation for linkgit:git-receive-pack[1]. OPTIONS[[OPTIONS]] @@ -710,6 +715,7 @@ a `git gc` command on the origin repository. include::transfer-data-leaks.adoc[] +[[CONFIGURATION]] CONFIGURATION ------------- |
