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

Re: push docs: inaccurate description of omitted destination?

From
Junio C Hamano <gitster@pobox.com>
Date
May 13, 2019, 09:18 UTC
Message-ID
<xmqqimuebtlu.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<87sgtj6mo3.fsf@kyleam.com>
Kyle Meyer <kyle@kyleam.com> writes:
Show 16 quoted lines
> It seems to me that push's manpage contains a couple of inaccurate (or
> at least confusingly incomplete) statements about omitting the
> destination part of the refspec.
>
> First, the refspec section of the manpage has this to say:
>
>     If `git push [<repository>]` without any `<refspec>` argument is set to
>     update some ref at the destination with `<src>` with
>     `remote.<repository>.push` configuration variable, `:<dst>` part can
>     be omitted--such a push will update a ref that `<src>` normally updates
>     without any `<refspec>` on the command line.  Otherwise, missing
>     `:<dst>` means to update the same ref as the `<src>`.
>
> Reading that, I'd think that, if I haven't configured
> remote.<repository>.push in a way that involves <src>, omitting <dst>
> will update the remote ref with the same name.

... if such a push would update the ref at the remote with the same name, yes. Otherwise no. And that is determined by what push mode is being used (e.g. are we using the matching mode? The current mode? Something else?).

>  But push.default is also
> consulted before falling back entirely to using the remote ref with the
> same name:

Yes. The push.default configuration participates in the selection of the ref at the remote that gets updated, given a refspec element with a missing :<dst>. And you do not have to write :<dst> to name the ref that a refspec with missing :<dst> would update anyway.

Show 9 quoted lines
>     `git push origin master`::
>        Find a ref that matches `master` in the source repository
>        (most likely, it would find `refs/heads/master`), and update
>        the same ref (e.g. `refs/heads/master`) in `origin` repository
>        with it.  If `master` did not exist remotely, it would be
>        created.
>
> Perhaps I'm misreading that, but I'd interpret that as saying the remote
> ref with the same name will always be updated,...

That part is random listing of examples with vanilla configuration, so depending on what setting you personally have, the behaviour may be different.

Previous: Kyle Meyer
Message 2 of 2 in “push docs: inaccurate description of omitted destination?”
  1. Kyle MeyerMay 13, 2019
  2. Junio C HamanoMay 13, 2019

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.