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

git push doesn't use local branch name as default

From
Mathias Kunter <mathiaskunter@gmail.com>
Date
May 28, 2021, 06:29 UTC
Message-ID
<fcf30899-8e64-5417-f478-14d6aca72544@gmail.com>
In-Reply-To
<3b9bc214-a30a-ba49-af96-7eeaf37b7bbd@gmail.com>
Felipe,
thanks for your reply.
> Sounds like you want to change the default to `push.default=current`.

Yes, but shouldn't `simple` pushing also work? The documentation says about `push.default=simple`:

> When pushing to a remote that is different from the remote you normally
> pull from, work as `current`.

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?

If `simple` pushing is used, it doesn't seem to make sense for me to fallback to `current` on branches which *do* have an upstream, but to error out on branches which do *not* have an upstream.

Cheers Mathias Kunter

Am 27.05.21 um 21:51 schrieb Felipe Contreras:
Show 37 quoted lines
> Mathias Kunter wrote:
>> Hi all,
>>
>> at https://git-scm.com/docs/git-push#_description it says:
>>
>>> When neither the command-line nor the configuration specify what to
>>> push, the default behavior is used, which corresponds to the simple
>>> value for push.default: the current branch is pushed to the
>>> corresponding upstream branch, but as a safety measure, the push is
>>> aborted if the upstream branch does not have the same name as the local
>>> one.
>>
>> However, on a branch which does *not* have an upstream branch
>> configured, the command
>>
>>> git push <remote_name>
>>
>> doesn't use the local branch name as default,
> 
> Yes it does, but only on the src side of the refspec. Something like:
> 
>    git push <remote_name> <branch_name>:
> 
> (invalid refspec)
> 
> Note the remote side is missing, so git doesn't know where to push to.
> 
>> Note that it *does* work if the remote branch name is explicitly specified:
>>
>>> git push <remote_name> <branch_name>
> 
> In that case git assumes you mean <branch_name>:<branch_name>.
> 
> Sounds like you want to change the default to `push.default=current`.
> 
> Cheers.
> 
Next: Elijah Newren
Message 1 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.