git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3 4/4] doc: git-push: clarify "what to push"

From
Julia Evans <julia@jvns.ca>
Date
Sep 26, 2025, 17:31 UTC
Message-ID
<442a4f25-7d7b-4f34-9e2c-ce396277e7be@app.fastmail.com>
In-Reply-To
<xmqqwm5lcjvy.fsf@gitster.g>
On Fri, Sep 26, 2025, at 11:29 AM, Junio C Hamano wrote:
Show 26 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
>
>>> But I'm not sure it's true in this case: we just said above that
>>> "The default is `push.default=simple`, which will push to a branch with
>>> the same name as the current branch."
>>
>> So I think this simplified statement is what causes confusion.  It
>> says push.default=simple will push to such and such place, but that
>> is not true....
>
> After sleeping on this, I do think that at the crux of confusing
> wording in the current draft is the lack of stress on "simple" being
> a narrower special case of more general "upstream" for various
> push.default modes.  In either of these modes, unless told otherwise
> with the configuration file or the command line arguments, "git
> push" pushes to update the upstream of the current branch.  There
> is, as you said, an additional safety measure in the "simple" mode,
> that rejects a configuration to have a branch whose name is
> different in the remote repository as the upstream branch.
>
> In other words, the push.default=simple mode does not tell Git to
> push to a branch with the same name.  Rather, as a variant of the
> push.default=upstream mode, it tells Git to follow the same "push to
> the upstream branch" rule, which requires you to configure your
> upstream.  But the mode gives additional limit on the name of the
> branch that can be set to upstream.

I like the idea of explaining it as "push.default=simple uses the configured upstream branch, with the restriction that the upstream branch must have the same name".

But as I learned from you earlier in this thread: https://lore.kernel.org/git/pull.1964.v2.git.1757703309.gitgitgadget@gmail.com/T/#m896f4a32ca462d69637b56f9bdfaa61e55e6b952 push.default=simple will sometimes push the current branch to the remote branch with the same name even if there's no configured upstream branch.

So it seems more accurate to say that push.default.simple will push to the branch with the same name, with the restriction that you might have to set an upstream, because the branch must always have the same name, but whether or not you have to set an upstream depends on the situation.

Personally that behaviour seems unintuitive to me: I always thought that push.default=simple _did_ require you to set an upstream branch and after spending many hours thinking about I still can't really describe in a way that feels satisfactory to me why it sometimes doesn't and under what conditions that happens.

One idea I had was to change Git's behaviour so that push.default=simple _does_ require you to set an upstream branch, and then we could document that behaviour. That's how it used to work when push.default=simple was originally created and it's not clear to me if the change to make push.default=simple _not_ always require you to set an upstream was intentional or not. I did a git bisect to find out when this changed, and it was in https://github.com/git/git/commit/ed2b18292bfeedc98c9e2b6bd8a35d8001dab2fc commit ed2b18292bfeed

I tried to write a patch to require setting an upstream branch, though my commit message has some mistakes and I'm not at all sure of my understanding of the code. https://github.com/jvns/git/commit/3553479892b11c50de939707e7f00aa7c7cb2f9d

Show 36 quoted lines
> We should make our text clear enough that anybody who read about the
> push.default=simple configuration easily understand the above.  We
> would need to find a good division between what to put in the main
> text and what to leave out to the "see ... for more detauls" part to
> guide those who read about "git push" command to the same
> realization without bombarding them with descriptions of full range
> of possible values of push.default.
>
> Peeking our earlier exchange to help me formulate my thinking a
> bit...
>
>> +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 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 section below for more on `push.default`.
>> +
>> +As a safety measure, `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 section below for more on how to set and
>> +use upstreams.
>
> ... here is my attempt.
>
>     3. The `push.default` configuration. The default is `simple`,
>        which is a variant of `upstream`.  In either mode, "git push"
>        updates the configured upstream branch (see the UPSTREAM
>        BRANCHES section for more on how to set and use upstreams).
>        The 'simple' mode has an additional limitation that the name
>        of your configured upstream must be the same as your branch.
>
> (iow, I rolled the "As a safety measure" paragraph into 3. itself).
Previous: Junio C HamanoNext: Junio C Hamano
Message 55 of 87 in “doc: git-push: clarify DESCRIPTION section & refspec definition”
  1. 0/4 doc: git-push: clarify DESCRIPTION section & refspec definitionJulia Evans via GitGitGadget, Aug 26, 2025
  2. 1/4 doc: git-push: update introJulia Evans via GitGitGadget, Aug 26, 2025
  3. D. Ben KnobleAug 28, 2025
  4. Junio C HamanoAug 28, 2025
  5. Kristoffer HaugsbakkAug 29, 2025
  6. Julia EvansAug 28, 2025
  7. D. Ben KnobleAug 28, 2025
  8. 2/4 doc: git-push: clarify "where to push"Julia Evans via GitGitGadget, Aug 26, 2025
  9. Junio C HamanoAug 27, 2025
  10. 3/4 doc: git-push: clarify "what to push"Julia Evans via GitGitGadget, Aug 26, 2025
  11. Junio C HamanoAug 26, 2025
  12. Julia EvansAug 27, 2025
  13. D. Ben KnobleAug 28, 2025
  14. 4/4 doc: git-push: rewrite refspec specificationJulia Evans via GitGitGadget, Aug 26, 2025
  15. Junio C HamanoAug 26, 2025
  16. Julia EvansAug 27, 2025
  17. D. Ben KnobleAug 28, 2025
  18. 0/4 doc: git-push: clarify DESCRIPTION section & refspec definitionJulia Evans via GitGitGadget, Sep 12, 2025
  19. 1/4 doc: git-push: clarify introJulia Evans via GitGitGadget, Sep 12, 2025
  20. Junio C HamanoSep 12, 2025
  21. Julia EvansSep 15, 2025
  22. Junio C HamanoSep 16, 2025
  23. Julia EvansSep 16, 2025
  24. Ben KnobleSep 16, 2025
  25. Junio C HamanoSep 16, 2025
  26. Junio C HamanoSep 17, 2025
  27. Julia EvansSep 18, 2025
  28. 2/4 doc: add an UPSTREAM BRANCHES section to pull/push/fetchJulia Evans via GitGitGadget, Sep 12, 2025
  29. Junio C HamanoSep 12, 2025
  30. Julia EvansSep 15, 2025
  31. Junio C HamanoSep 15, 2025
  32. Julia EvansSep 15, 2025
  33. Junio C HamanoSep 16, 2025
  34. Junio C HamanoSep 16, 2025
  35. Junio C HamanoSep 16, 2025
  36. Julia EvansSep 18, 2025
  37. 3/4 doc: git-push: clarify "where to push"Julia Evans via GitGitGadget, Sep 12, 2025
  38. Junio C HamanoSep 12, 2025
  39. Junio C HamanoSep 12, 2025
  40. Julia EvansSep 15, 2025
  41. 4/4 doc: git-push: clarify "what to push"Julia Evans via GitGitGadget, Sep 12, 2025
  42. 0/4 doc: git-push: clarify DESCRIPTION sectionJulia Evans via GitGitGadget, Sep 23, 2025
  43. 1/4 doc: git-push: clarify introJulia Evans via GitGitGadget, Sep 23, 2025
  44. 2/4 doc: add an UPSTREAM BRANCHES section to pull/push/fetchJulia Evans via GitGitGadget, Sep 23, 2025
  45. Junio C HamanoSep 24, 2025
  46. Julia EvansSep 30, 2025
  47. 3/4 doc: git-push: clarify "where to push"Julia Evans via GitGitGadget, Sep 23, 2025
  48. 4/4 doc: git-push: clarify "what to push"Julia Evans via GitGitGadget, Sep 23, 2025
  49. Junio C HamanoSep 24, 2025
  50. Julia EvansSep 25, 2025
  51. Junio C HamanoSep 25, 2025
  52. Julia EvansSep 25, 2025
  53. Junio C HamanoSep 26, 2025
  54. Junio C HamanoSep 26, 2025
  55. Julia EvansSep 26, 2025
  56. Junio C HamanoSep 26, 2025
  57. Julia EvansSep 26, 2025
  58. Junio C HamanoSep 26, 2025
  59. D. Ben KnobleSep 28, 2025
  60. D. Ben KnobleSep 23, 2025
  61. 0/5 doc: git-push: clarify DESCRIPTION sectionJulia Evans via GitGitGadget, Sep 30, 2025
  62. 1/5 doc: git-push: clarify introJulia Evans via GitGitGadget, Sep 30, 2025
  63. 2/5 doc: add an UPSTREAM BRANCHES section to pull/push/fetchJulia Evans via GitGitGadget, Sep 30, 2025
  64. Junio C HamanoSep 30, 2025
  65. Julia EvansOct 3, 2025
  66. Junio C HamanoOct 3, 2025
  67. Jean-Noël AVILAOct 1, 2025
  68. Julia EvansOct 3, 2025
  69. 3/5 doc: git-push: clarify "where to push"Julia Evans via GitGitGadget, Sep 30, 2025
  70. 4/5 doc: git-push: clarify "what to push"Julia Evans via GitGitGadget, Sep 30, 2025
  71. Junio C HamanoSep 30, 2025
  72. Jean-Noël AVILAOct 1, 2025
  73. 5/5 doc: git-push: Add explanation of `git push origin main`Julia Evans via GitGitGadget, Sep 30, 2025
  74. D. Ben KnobleOct 1, 2025
  75. Julia EvansOct 3, 2025
  76. D. Ben KnobleOct 1, 2025
  77. 0/5 doc: git-push: clarify DESCRIPTION sectionJulia Evans via GitGitGadget, Oct 6, 2025
  78. 1/5 doc: git-push: clarify introJulia Evans via GitGitGadget, Oct 6, 2025
  79. 2/5 doc: add an UPSTREAM BRANCHES section to pull/push/fetchJulia Evans via GitGitGadget, Oct 6, 2025
  80. Kristoffer HaugsbakkOct 7, 2025
  81. Julia EvansOct 7, 2025
  82. D. Ben KnobleOct 7, 2025
  83. 3/5 doc: git-push: clarify "where to push"Julia Evans via GitGitGadget, Oct 6, 2025
  84. 4/5 doc: git-push: clarify "what to push"Julia Evans via GitGitGadget, Oct 6, 2025
  85. 5/5 doc: git-push: Add explanation of `git push origin main`Julia Evans via GitGitGadget, Oct 6, 2025
  86. D. Ben KnobleOct 6, 2025
  87. Junio C HamanoOct 6, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.