git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Bert Wesarg <bert.wesarg@googlemail.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] doc: clarify "explicitly given" in push.default
Date: Mon, 27 Jan 2020 20:48:01 +0100	[thread overview]
Message-ID: <dfcf0201-b634-2274-f041-a6ec4491825a@googlemail.com> (raw)
In-Reply-To: <d8007df9-002b-6db1-4769-d6bf8c338cdf@googlemail.com>

Dear Jeff,

On 27.01.20 08:00, Bert Wesarg wrote:
> On 25.01.20 21:05, Jeff King wrote:
>> On Sat, Jan 25, 2020 at 08:38:04AM +0100, Bert Wesarg wrote:
>>
>>> thanks for this pointer. My initial pointer was the help for push.default:
>>>
>>>   From git-config(1):
>>>
>>>         push.default
>>>             Defines the action git push should take if no refspec is explicitly
>>>             given. Different values are well-suited for specific workflows; for
>>>
>>> Thus I expected, that this takes effect, when just calling 'git push'.
>>
>> Yeah, I agree "explicitly given" is vague there. Perhaps the patch below
>> is worth doing?
>>
>>> What I actually want to achieve, is to track a remote branch with a
>>> different name locally, but 'git push' should nevertheless push to
>>> tracked remote branch.
>>>
>>> In my example above, befor adding the 'push.origin.push' refspec, rename the branch:
>>>
>>>      $ git branch -m local
>>>      $ git push --dry-run
>>>        To ../bare.git
>>>         * [new branch]      local -> local
>>>
>>> Is it possible that this pushes to the tracked branch automatically,
>>> and because I have multiple such branches, without the use of a push
>>> refspec.
>>
>> I think if push.default is set to "upstream" then it would do what you
>> want as long as you set the upstream of "local" (e.g., by doing "git
>> branch --set-upstream-to=origin/master local).
> 
> Thanks. This pushes only the current branch and honors the 'rename'.

while this works …

> 
>>
>> There's another way of doing this, which is when you have a "triangular"
>> flow: you might pull changes from origin/master into your local branch
>> X, but then push them elsewhere. Usually this would be pushing to a
>> branch named X on a different remote than origin (e.g., your public fork
>> of upstream on a server). And for that you can set branch.X.pushRemote.

… it does not play well if you have have both flows in one repository. And I do have both flows. I track the upstream 'master' in the local branch 'Y' and I have also a branch 'X' which is based on 'Y' but should be pushed to a different remote as branch 'Y'. I have configured 'branch.X.pushRemote = triangular' but with 'push.default' set to 'upstream' I get this when:

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

In this simple case, without a renaming, I would expect that 'git push' just works. May be just fallback to 'simple' if 'upstream' does not resolve to a fully qualified push?

Best,
Bert

  parent reply	other threads:[~2020-01-27 19:48 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-24 20:29 [Q] push refspec with wildcard pushes all matching branches Bert Wesarg
2020-01-25  0:38 ` Jeff King
2020-01-25  7:38   ` Bert Wesarg
2020-01-25 20:05     ` [PATCH] doc: clarify "explicitly given" in push.default Jeff King
2020-01-27  7:00       ` Bert Wesarg
2020-01-27  7:02         ` Jeff King
2020-01-27  9:25           ` Bert Wesarg
2020-01-27 23:12             ` Jeff King
2020-01-28 22:11             ` Junio C Hamano
2020-01-29  2:41               ` Jeff King
2020-01-29  5:21                 ` Junio C Hamano
2020-01-29  5:53                   ` Jeff King
2020-01-27 19:48         ` Bert Wesarg [this message]
2020-01-27 20:53           ` Bert Wesarg
2020-01-27 23:14           ` Jeff King
2020-01-28 20:48             ` Bert Wesarg

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=dfcf0201-b634-2274-f041-a6ec4491825a@googlemail.com \
    --to=bert.wesarg@googlemail.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).