From: "Santi Béjar" <santi@agolina.net>
To: "Bill Lear" <rael@zopyra.com>
Cc: git@vger.kernel.org
Subject: Re: Using the --track option when creating a branch
Date: Wed, 29 Oct 2008 17:25:37 +0100 [thread overview]
Message-ID: <adf1fd3d0810290925s493cdc6oc7534904c864db28@mail.gmail.com> (raw)
In-Reply-To: <18696.32778.842933.486171@lisa.zopyra.com>
On Wed, Oct 29, 2008 at 4:23 PM, Bill Lear <rael@zopyra.com> wrote:
> We have had a few "crossed stream" problems when developers are
> working on a local branch and they do an unguarded git push/pull,
> when they really intended to do git push/pull origin branchname.
>
> We use git in a way that makes it desirable for us to only push/pull
> to the same remote branch. So, if I'm in branch X, I want 'git push'
> to push to origin/X, and 'git pull' to fetch into origin/X and then
> merge into X from origin/X.
>
> In other words, we want git push/pull to behave in branches other than
> master the same way it does when in master.
>
> I have discovered the '--track' option when creating a local branch,
> and this appears to me to be the thing that gives us the desired
> behavior.
branch.autosetupmerge controls if --track is used by default (it is
true by default since a long time)
(See "git help config" for details)
>
> Before I tell the rest of the team that this is the correct way
> to do things, I need to be sure I am correct, so if anyone here
> can confirm or deny this, I'd appreciate it.
It should just work (at least in the lastest releases) when creating a
branch from a remote branch.
$ git checkout -b X origin/X
or
$ git branch X origin/X
Branch X set up to track remote branch refs/remotes/origin/X
>
> Also, once a branch has been created, how can we add a '--track' option
> after the fact?
It it just two configs (apart from the remote repository). A help
message should appear when using "git pull" without arguments and it
cannot figure out the branch to merge:
$ # currently in branch next
$ git pull
You asked me to pull without telling me which branch you
want to merge with, and 'branch.next.merge' in
your configuration file does not tell me either. Please
name which branch you want to merge on the command line and
try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details on the refspec.
If you often merge with the same branch, you may want to
configure the following variables in your configuration
file:
branch.next.remote = <nickname>
branch.next.merge = <remote-ref>
remote.<nickname>.url = <url>
remote.<nickname>.fetch = <refspec>
See git-config(1) for details.
[end]
so to add it after the fact you should execute:
$ git config branch.next.remote origin
$ git config branch.next.merge refs/heads/next
>
> Finally, is there a 'global' config setting that would set this behavior
> for all repos (new or existing)?
See above.
>
> We are using git 1.6.* versions here, mostly.
>
Santi
next prev parent reply other threads:[~2008-10-29 16:27 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-29 15:23 Using the --track option when creating a branch Bill Lear
2008-10-29 16:25 ` Santi Béjar [this message]
2008-10-29 20:33 ` Bill Lear
2008-10-30 5:12 ` Sam Vilain
2008-10-30 12:04 ` Bill Lear
2008-10-30 12:12 ` Bill Lear
2008-10-30 12:25 ` Andreas Ericsson
2008-10-30 13:52 ` Samuel Tardieu
2008-10-30 14:06 ` Andreas Ericsson
2008-10-30 14:23 ` Samuel Tardieu
2008-10-30 14:41 ` Pierre Habouzit
2008-10-30 14:56 ` Samuel Tardieu
2008-10-30 18:00 ` Sam Vilain
2008-10-30 14:54 ` Andreas Ericsson
2008-10-30 15:04 ` Samuel Tardieu
2008-10-30 15:25 ` Andreas Ericsson
2008-10-30 15:42 ` Bill Lear
2008-10-30 19:13 ` Marc Branchaud
2008-10-30 17:57 ` Sam Vilain
2008-10-30 23:24 ` Jakub Narebski
2008-11-02 4:23 ` Jeff King
2008-10-30 16:44 ` Sam Vilain
2008-10-30 12:41 ` Santi Béjar
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=adf1fd3d0810290925s493cdc6oc7534904c864db28@mail.gmail.com \
--to=santi@agolina.net \
--cc=git@vger.kernel.org \
--cc=rael@zopyra.com \
/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.
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 NNTP newsgroup(s).