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

Re: [PATCH 4/4] doc: git-push: rewrite refspec specification

From
Julia Evans <julia@jvns.ca>
Date
Aug 27, 2025, 13:10 UTC
Message-ID
<15c8cf10-e1a1-404a-8a99-d2aab098104a@app.fastmail.com>
In-Reply-To
<xmqqsehdfyho.fsf@gitster.g>
Show 10 quoted lines
>> +`:<dst>` is optional.
>
> It may be technically true, but I am not sure if it is a good idea
> to say it here.  Without "when missing, <dst> is inferred with these
> rules", saying just "is optional" naturally invites a puzzlement:
> when do we need to supply it and for what?
>
> As you are going to say what happens when you omit it very soon, and
> you already have said with [:<dst>] that it is optional, perhaps you
> can scratch this sentence.

The reason I mentioned this early on is that when I read this for the first time it was quite confusing. Since `main` (or another branch name on its own) was the only push refspec I had experience using, it was disorienting to be told that the format was `<src>:<dst>`. It made me wonder if maybe `main` was not a refspec after all and I'd misunderstood the SYNOPSIS.

I know that I'm not alone in this: it's very common for Git users (even very experienced ones!) to learn the form `git push origin main`, but to otherwise not be familiar at all with the concept of a "refspec". So I'd like to do something here to help those folks connect their existing knowledge to the broader concept of a "refspec".

That said `:<dst> is optional` may not be necessary: I think the examples here accomplish more or less the same thing.

>>  +The format for a refspec is [+]<src>[:<dst>], for example `main`,
> > +`main:other`, or `HEAD^:refs/heads/main`.
Show 7 quoted lines
>> +`+` is optional and does the same thing as `--force`.
>
> Ditto; this one is less bad than the :<dst> thing, because at least
> it tells us what it means.  But we are going to talk about when an
> update is not allowed (we haven't even hinted that some updates may
> not be allowed yet) much later, "the same as `--force`" is probably
> a bit premature at this point in the documentation.

The reason I mentioned this so early is similar -- It's very common for experienced users to be familiar with the `--force` option, and so this is a quick way to explain to them what the `+` does.

As an aside, I noticed while reading this that it looks like the description of `--force` right now is not quite accurate, since the rule about pushing to tags is not "it must be an ancestor".

>--force::
>	Usually, the command refuses to update a remote ref that is
>	not an ancestor of the local ref used to overwrite it.

I'm going to think about whether there's a way to format the "rules for updates" so that they can be referred to from the `--force` section. Or maybe just move them to the `--force` option, and refer people there if they want to understand exactly when `--force` is required.

It's certainly much more common for users to use `--force` to force a push than to use `+`, from that perspective it would make more sense to document the rules next to `--force` than next to the description of `+`.

Show 5 quoted lines
>> +You can write a refspec using the fully expanded form (for
>> +example `main:refs/heads/main`) which specifies the exact source
>
> This example is not fully expanded.  refs/heads/main:refs/heads/main
> would be, though.
Makes sense, will change.
> I am not sure it is easier to read with numbered list.  It is not
> like these rules are applied in this order, or anything like that,
> right?

I had a similar concern. I'm still trying to figure out how to manage unordered lists, since lists with a `*` are formatted by AsciiDoc in a weird way in the terminal: there's a tab character after the • character which I don't understand the reason for.

Show 9 quoted lines
> A tangent.
> Is this a refspec you can write in .git/config, e.g.
>
> 	[remote "origin"]
> 		push = tag v1.0"
>
> If not, it might be easier to explain if we tweaked the command line
> synopsis to say that the command takes, after the destination
> repository, zero or more refspec or "tag <tag>".  I dunno.
I checked and it's not a valid refspec:

$ git push fatal: invalid refspec 'tag v1.0'

This list seems like a more natural place for that information than the synopsis though: the synopsis is already quite hard to read and we can't use it as the only place to communicate that information. I can add a note to say that 'tag v1.0' is technically not a refspec. Git already has enough weird exceptions like that that I don't think it'll be too jarring.

> Perhaps move it down together with the "push void to remove"
> at the top of the list?
I'll also move it down.
> Good.  Somehow we have added the description of these to "git fetch"
> side, without updating "git push" side of the documentation.

Yes, I copied this part from the `git fetch` documention after checking that they worked with `git push` as well.

Show 18 quoted lines
>> +    Deletions are always accepted without a leading `+` in the
>> +    refspec (or `--force`), except when forbidden by configuration or hooks.
>
> This can be read in two ways, making two opposing answers to this
> question possible: when forbidden, can you make a deletion accepted
> by giving a `+` in front?
> "except when forbidden, deletions are accepted with or without `+`"
> might be less confusion-prone, but I dunno.  I just wanted to make
> sure that it is clear that forcing or prepending `+` would not
> change anything when forbidden by configuration or hooks on the
> remote end.
> 
> But because you haven't mentioned that not all updates are allowed,
> this might be a bit out of place in this list.  How about limiting
> this bullet point to only say that this is the syntax to use to
> delete a ref from the remote, and move the "deletions do not have to
> be forced and operations forbidden at the remote cannot be forced
> anyway" down, near the "Not all updates are allowed" below ...
Will do, that's much cleaner.
>> +    See `receive.denyDeletes` in linkgit:git-config[1] and `pre-receive` and
>> +    `update` in linkgit:githooks[5].
>
> ... together with this?
This makes sense.
- Julia
Previous: Junio C HamanoNext: D. Ben Knoble
Message 16 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.