{"thread":{"id":"55783","subject":"git push doesn't use local branch name as default","startedAt":"2021-05-27T17:06:33Z","lastAt":"2021-05-27T19:51:51Z","messageCount":2,"participants":["Mathias Kunter","Felipe Contreras"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"425693","messageId":"065528bf-b496-83d3-767d-2a78e50a9edf@gmail.com","threadId":"55783","inReplyTo":null,"subject":"git push doesn't use local branch name as default","fromName":"Mathias Kunter","fromEmail":"mathiaskunter@gmail.com","sentAt":"2021-05-27T17:06:25Z","receivedAt":"2021-05-27T17:06:33Z","isPatch":false,"sender":{"key":"mathiaskunter@gmail.com","avatar":"https://gravatar.com/avatar/131a813ba8d2cb36edb0d102971af5b523bad01aa9c842822e0d068b350bc4e8?d=mp&s=160"},"body":"Hi all,\n\nat https://git-scm.com/docs/git-push#_description it says:\n\n> When neither the command-line nor the configuration specify what to\n> push, the default behavior is used, which corresponds to the simple\n> value for push.default: the current branch is pushed to the\n> corresponding upstream branch, but as a safety measure, the push is\n> aborted if the upstream branch does not have the same name as the local\n> one.\n\nHowever, on a branch which does *not* have an upstream branch \nconfigured, the command\n\n> git push <remote_name>\n\ndoesn't use the local branch name as default, but fails with an error \ninstead:\n\n> fatal: The current branch master has no upstream branch.\n> To push the current branch and set the remote as upstream, use\n> \n> git push --set-upstream <remote_name> master\n\nNote that it *does* work if the remote branch name is explicitly specified:\n\n> git push <remote_name> <branch_name>\n\nBut shouldn't this also work without having to explicitly specify the \nremote branch name, and default to the local branch name instead?\n\n\n[System Info]\ngit version:\ngit version 2.31.1.windows.1\ncpu: x86_64\nbuilt from commit: c5f0be26a7e3846e3b6268d1c6c4800d838c6bbb\nsizeof-long: 4\nsizeof-size_t: 8\nshell-path: /bin/sh\nfeature: fsmonitor--daemon\nuname: Windows 10.0 19042\ncompiler info: gnuc: 10.2\nlibc info: no libc information available\n$SHELL (typically, interactive shell): <unset>\n\n\n[Enabled Hooks]\n"},{"id":"425706","messageId":"60aff85261fcf_26530208a@natae.notmuch","threadId":"55783","inReplyTo":"065528bf-b496-83d3-767d-2a78e50a9edf@gmail.com","subject":"RE: git push doesn't use local branch name as default","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-05-27T19:51:46Z","receivedAt":"2021-05-27T19:51:51Z","isPatch":false,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Mathias Kunter wrote:\n> Hi all,\n> \n> at https://git-scm.com/docs/git-push#_description it says:\n> \n> > When neither the command-line nor the configuration specify what to\n> > push, the default behavior is used, which corresponds to the simple\n> > value for push.default: the current branch is pushed to the\n> > corresponding upstream branch, but as a safety measure, the push is\n> > aborted if the upstream branch does not have the same name as the local\n> > one.\n> \n> However, on a branch which does *not* have an upstream branch \n> configured, the command\n> \n> > git push <remote_name>\n> \n> doesn't use the local branch name as default,\n\nYes it does, but only on the src side of the refspec. Something like:\n\n  git push <remote_name> <branch_name>:\n\n(invalid refspec)\n\nNote the remote side is missing, so git doesn't know where to push to.\n\n> Note that it *does* work if the remote branch name is explicitly specified:\n> \n> > git push <remote_name> <branch_name>\n\nIn that case git assumes you mean <branch_name>:<branch_name>.\n\nSounds like you want to change the default to `push.default=current`.\n\nCheers.\n\n-- \nFelipe Contreras\n"}]}