git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git push doesn't use local branch name as default
@ 2021-05-27 17:06 Mathias Kunter
  2021-05-27 19:51 ` Felipe Contreras
  0 siblings, 1 reply; 14+ messages in thread
From: Mathias Kunter @ 2021-05-27 17:06 UTC (permalink / raw)
  To: git

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, but fails with an error 
instead:

> fatal: The current branch master has no upstream branch.
> To push the current branch and set the remote as upstream, use
> 
> git push --set-upstream <remote_name> master

Note that it *does* work if the remote branch name is explicitly specified:

> git push <remote_name> <branch_name>

But shouldn't this also work without having to explicitly specify the 
remote branch name, and default to the local branch name instead?


[System Info]
git version:
git version 2.31.1.windows.1
cpu: x86_64
built from commit: c5f0be26a7e3846e3b6268d1c6c4800d838c6bbb
sizeof-long: 4
sizeof-size_t: 8
shell-path: /bin/sh
feature: fsmonitor--daemon
uname: Windows 10.0 19042
compiler info: gnuc: 10.2
libc info: no libc information available
$SHELL (typically, interactive shell): <unset>


[Enabled Hooks]

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-05-30 16:32 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <3b9bc214-a30a-ba49-af96-7eeaf37b7bbd@gmail.com>
2021-05-28  6:29 ` git push doesn't use local branch name as default Mathias Kunter
2021-05-28  7:00   ` Elijah Newren
2021-05-28  7:44     ` Mathias Kunter
2021-05-28  8:51       ` Mathias Kunter
2021-05-28 21:12         ` git push default doesn't make sense Felipe Contreras
2021-05-30 16:28           ` Mathias Kunter
2021-05-30 16:32             ` Felipe Contreras
2021-05-28 17:52       ` git push doesn't use local branch name as default Felipe Contreras
2021-05-28 17:22     ` Felipe Contreras
2021-05-28 17:44       ` Elijah Newren
2021-05-28 18:58         ` Felipe Contreras
2021-05-28 17:10   ` Felipe Contreras
2021-05-27 17:06 Mathias Kunter
2021-05-27 19:51 ` Felipe Contreras

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).