public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Ximin Luo <infinity0@gmx•com>
To: git@vger•kernel.org
Subject: push.default=upstream doesn't play nicely with remote.pushdefault/branch.*.pushremote
Date: Tue, 10 Sep 2013 14:10:57 +0100	[thread overview]
Message-ID: <522F1A61.3010805@gmx.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1713 bytes --]

(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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 897 bytes --]

             reply	other threads:[~2013-09-10 13:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-10 13:10 Ximin Luo [this message]
2013-09-10 16:06 ` push.default=upstream doesn't play nicely with remote.pushdefault/branch.*.pushremote Junio C Hamano
2013-09-11  0:38 ` Felipe Contreras

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=522F1A61.3010805@gmx.com \
    --to=infinity0@gmx$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox