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

push.default=upstream doesn't play nicely with remote.pushdefault/branch.*.pushremote

From
XLXimin Luo <infinity0@gmx.com>
Date
Sep 10, 2013, 13:10 UTC
Message-ID
<522F1A61.3010805@gmx.com>
(Please CC me as I am not subscribed.)

$ git config -l | grep '^branch.master\|^push.' push.default=upstream branch.master.remote=upstream branch.master.merge=refs/heads/master branch.master.pushremote=origin

$ git branch
* master

$ git push fatal: You are pushing to remote 'origin', which is not the upstream of your current branch 'master', without telling me what to push to update which remote branch.

push.default=upstream means "push back where it came from (*)". However, if I specifically define remote.pushdefault or branch.*.pushremote, this clearly means I don't want to do (*) in this case.
The question here then is, what remote branch should git push to - since pushremote only specifies a repo? I can suggest two options:
- A: push to branch.*.merge if it's defined; otherwise push to <current branch> (like push.default=current)
- B: push to <current branch> regardless
B is probably simpler and means you can amend the push.default manual entry more easily:
upstream: [..] This mode only makes sense if you are pushing to the same repository you would normally pull from (i.e. central workflow). <INS>If you are not pushing to the same repository, acts as "current".</INS>
(Note again; that this is a special case when push.default=upstream because of the "this mode only makes sense" semantics. The other values for push.default are simpler and do not result in a conflict.)
Alternatively, an even more simple behaviour is to adjust the error message to communicate the root cause:

$ git push fatal: branch.*.pushremote is not compatible with push.default = upstream

X
-- 
GPG: 4096R/1318EFAC5FBBDBCE
git://github.com/infinity0/pubkeys.git
Next: Junio C Hamano
Message 1 of 3 in “push.default=upstream doesn't play nicely with remote.pushdefault/branch.*.pushremote”
  1. Ximin LuoSep 10, 2013
  2. Junio C HamanoSep 10, 2013
  3. Felipe ContrerasSep 11, 2013

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.