public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Nick <oinksocket@letterboxes•org>
To: Jeff King <peff@peff•net>
Cc: git@vger•kernel.org, Stephen Bash <bash@genarts•com>
Subject: Re: git push on tracking branches
Date: Mon, 27 Sep 2010 18:16:40 +0100	[thread overview]
Message-ID: <4CA0D178.6070704@letterboxes.org> (raw)
In-Reply-To: <20100927160548.GA10256@sigill.intra.peff.net>

On 27/09/10 17:05, Jeff King wrote:
> On Mon, Sep 27, 2010 at 12:00:41PM -0400, Stephen Bash wrote:
> 
>> A coworker alerted me to some strange behavior with git push on tracking branches (maybe a documentation error?).  Pro Git (http://progit.org/book/ch3-5.html) says:
>>
>> "To set up a local branch with a different name than the remote branch, you can easily use the first version with a different local branch name:
>>    $ git checkout -b sf origin/serverfix
>>    Branch sf set up to track remote branch refs/remotes/origin/serverfix.
>>    Switched to a new branch "sf"
>> Now, your local branch sf will automatically push to and pull from origin/serverfix."
> 
> That has never been the case by default. Push has always defaulted to
> pushing all matching branches (so of course if you use the same name, it
> will end up pushing to the tracking branch).  However, you can do:
> 
>   git config --global push.default tracking
> 
> to explicitly change the default to push the current branch to its
> upstream. See the entry for "push.default" in "git help config".

The "tracking" setting does seem more sensible and intuitive, given that current
git practice requires setting up explicit tracking relationships between branches.

For example, I find it surprising, perhaps even alarming, that by default, git
will try and push my changes on branch A to the branch origin/A - even if I
created it to track origin/B.  Why allow the possibility of A tracking a
non-matching branch origin/B, and have the default push setting ignore that?

Not only that, but I frequently get asked by puzzled colleagues, new to git, why
"git push" seems to fail all the time when they're pushing their changes.  (The
errors arise because of the default "matching" setting: many of the matching
branches fail to push cleanly because the remote branch has silently changed. My
latest answer is to tell them to set push.default to "tracking", or to do that
for them.)


I'm curious: why isn't "tracking" the default and recommended option?
"Historical reasons" might explain the first, but not the second.


- Nick

  parent reply	other threads:[~2010-09-27 17:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <6958088.371432.1285602164529.JavaMail.root@mail.hq.genarts.com>
2010-09-27 16:00 ` git push on tracking branches Stephen Bash
2010-09-27 16:05   ` Jeff King
2010-09-27 16:14     ` Stephen Bash
2010-09-27 17:16     ` Nick [this message]
2010-09-27 17:53       ` Jeff King

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=4CA0D178.6070704@letterboxes.org \
    --to=oinksocket@letterboxes$(echo .)org \
    --cc=bash@genarts$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=peff@peff$(echo .)net \
    /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