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
Felipe Contreras <felipe.contreras@gmail.com>
Date
May 28, 2021, 18:58 UTC
Message-ID
<60b13d67cb8a7_e545b20876@natae.notmuch>
In-Reply-To
<CABPp-BEd2GAOSSAaUwMLhftiKsbFXmuszH_fXBbTY9nU=yWg9w@mail.gmail.com>
Elijah Newren wrote:
> On Fri, May 28, 2021 at 10:22 AM Felipe Contreras
> <felipe.contreras@gmail.com> wrote:
Show 15 quoted lines
> > 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.
I am sure it is, just like plenty of the official documentation.
> If so, maybe something like:
> 
> If you have a default remote configured for the current branch

This is still very hard to parse, especially since there's no command to "configure the remote of a branch" (AFAIK).

> and are pushing to a remote other than that one
And you've lost me.
I have to do a mental model of what's trying to be said:
  x && pushed != x
If x is nil, then I can't push to it, so this is the same as:
  pushed != x
> (or if you have no default remote configured and are pushing to a
> remote other than 'origin'),
So:
  !x && pushed != 'origin'
Altogether:
  (pushed != x) || (!x && pushed != 'origin')
So:
  pushed != (x || 'origin')

And we can use an x that is more friendly to users (and there are commands to set it):

  If you are pushing to a remote that is not the same as the upstream
  branch, or 'origin'...
> then work as 'current'.
And now I have to read what `current` is.

The current documentation is trying to replicate what the convoluted code is doing, your version is a little better, but not by much.

This is much more straightforward:
  pushes the current branch with the same name on the remote.
  If you are working on a centralized workflow--pushing to the same
  repository you pull from (typically `origin`)--then you need to
  configure an upstream branch with the same name.

When you describe the situation clearly (and not simply transcribe the code), it becomes clear why users like Mathias don't see the current behavior as sane.

I'm working on some patches so the issue becomes clear for those who don't speak user.

Cheers.
-- 
Felipe Contreras
Previous: Elijah NewrenNext: Felipe Contreras
Message 11 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.