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

Re: git push doesn't use local branch name as default

From
Elijah Newren <newren@gmail.com>
Date
May 28, 2021, 17:44 UTC
Message-ID
<CABPp-BEd2GAOSSAaUwMLhftiKsbFXmuszH_fXBbTY9nU=yWg9w@mail.gmail.com>
In-Reply-To
<60b126e8cf42e_51908208d4@natae.notmuch>

On Fri, May 28, 2021 at 10:22 AM Felipe Contreras <felipe.contreras@gmail.com> wrote:

Show 25 quoted lines
>
> Elijah Newren wrote:
> > > If there is no upstream, then there also is no "remote I normally pull
> > > from", and thus, according to the doc, `simple` should actually work
> > > like `current` in this case. Am I wrong here?
> >
> > The relevant code is
> >
> >     return (fetch_remote && fetch_remote != remote);
> >
> > so you only get the "current" behavior when fetch_remote is non-NULL.
>
> fetch_remote is practically never non-NULL.
>
> fetch_remote is remote_get(NULL), which is basically the equivalent of:
>
> remote_get(remote_for_branch(current_branch, ...));
>
> Typically when an upstream branch is not configured, this is the same
> as:
>
> remote_get("origin");
>
> The only time fetch_remote is NULL is when the configured remote is
> invalid.
Ah, thanks for correcting and clarifying here.
Show 15 quoted lines
>
> So you don't get the "current" behavior when pushing to "origin".
>
> Perhaps:
>
> --- a/Documentation/config/push.txt
> +++ b/Documentation/config/push.txt
> @@ -29,8 +29,8 @@ push.default::
>    different from the local one.
>  +
>  When pushing to a remote that is different from the remote you normally
> -pull from, work as `current`.  This is the safest option and is suited
> -for beginners.
> +pull from (typically "origin"), work as `current`.  This is the safest option
> +and is suited for beginners.

This is certainly an improvement. I wonder if it might still be considered ambiguous or hard to parse, though. If so, maybe something like:

If you have a default remote configured for the current branch and are pushing to a remote other than that one (or if you have no default remote configured and are pushing to a remote other than 'origin'), then work as 'current'.

It may also be helpful to move the "This is the safest option and is suited for beginners" out of its current paragraph and combine it with the "This mode has become the default" in the next paragraph.

Previous: Felipe ContrerasNext: Felipe Contreras
Message 10 of 12 in “git push doesn't use local branch name as default”
  1. Mathias KunterMay 28, 2021
  2. Elijah NewrenMay 28, 2021
  3. Mathias KunterMay 28, 2021
  4. Mathias KunterMay 28, 2021
  5. git push default doesn't make senseFelipe Contreras, May 28, 2021
  6. Mathias KunterMay 30, 2021
  7. Felipe ContrerasMay 30, 2021
  8. Felipe ContrerasMay 28, 2021
  9. Felipe ContrerasMay 28, 2021
  10. Elijah NewrenMay 28, 2021
  11. Felipe ContrerasMay 28, 2021
  12. Felipe ContrerasMay 28, 2021

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.