Re: [PATCH 3/4] doc: git-push: clarify "what to push"
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 26, 2025, 23:57 UTC
- Message-ID
- <xmqqldn5fxfi.fsf@gitster.g>
- In-Reply-To
- <ac554cbe75444880bbb2791c4d85dcf083d833d7.1756240823.git.gitgitgadget@gmail.com>
"Julia Evans via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 13 quoted lines
> -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`). > +To decide which branches, tags, or other refs to push, Git uses > +(in order of precedence): > + > +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 current branch > +3. The `push.default` configuration (See linkgit:git-config[1] for > + the meaning of `push.default`).
The use of numbered list does make very good sense here, as we (at least conceptually) examine these rules in the order.
Show 9 quoted lines
> 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. > +push, the current branch is pushed to the branch with the same name > +on the remote. The current branch must have a configured upstream with > +the same name, so this will fail when pushing a new branch.
Is the last sentence correct?
$ cd /var/tmp/playpen
$ git clone https://github.com/git/git src
$ git clone --no-local --bare src dst
$ cd src
$ git checkout -b alter
$ git commit -m 'empty' --allow-empty
$ git -c push.default=simple push ../dst
Enumerating objects: 1, done.
Counting objects: 100% (1/1), done.
Writing objects: 100% (1/1), 185 bytes | 92.00 KiB/s, done.
Total 1 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To ../dst
* [new branch] alter -> alterIn "src" repository that is a fresh clone without any customization, the current branch "alter" does not have any configured upstream.
Puzzled....