From: Tomas Carnecky Date: Wed, 01 Apr 2009 23:14:45 GMT Subject: Re: More help with "pull" please Message-ID: In-Reply-To: <450196A1AAAE4B42A00A8B27A59278E70A7D4E71@EXCHANGE.trad.tradestation.com> On Apr 2, 2009, at 12:53 AM, John Dlugosz wrote: >> When you create a branch, you can tell git which remote branch it >> tracks, like this: >> >> $ git branch --track mynext origin/next >> >> So whenever you are on brach 'mynext' and do a git-pull, it will >> fetch >> and merge origin/next. >> >> You can do the same with the git-checkout command: >> >> $ git checkout --track origin/next >> >> This will create a local branch 'next' which tracks 'origin/next' >> > > OK, that works by adding something to the config file, right? The > docs > don't say, but does mention "having Pull: lines for a > ". Does tracking add Pull: lines, or is that another > feature? I think Pull: lines are not used anymore in newer repositories. Tracking is done through the 'branch..remote' and 'branch..merge' config options (which are automatically set by git-branch/git-checkout when you use --track). >> >> $ git clone $url XXX >> $ cd XXX >> $ git checkout --track origin/ReleaseCandidate >> ... >> $ git pull # will automatically fetch and merge > origin/ReleaseCandidate > > According to the manpage on pull, "While git-pull run without any > explicit parameter takes default s from Pull: > lines, > it merges only the first found into the current branch, > after > fetching all the remote refs." > > Also, "When no refspec was given on the command line ... If > branch..merge configuration for the current branch > exists, > that is the name of the branch at the remote site that is merged." So > is that yet again different from having Pull: lines? If so, I'm > fine if > no "Pull:" lines exist, or it would merge the first refspec found > there. > > Also, "Normally the branch merged in is the HEAD of the remote > repository, but the choice is determined by the branch..remote > and > branch..merge options; see git-config(1) for details." That > agrees with the previous. If branch..merge configuration > exists, > I don't need to worry about the remote HEAD. I'd say forget about Pull: because you won't see any of that in newer repositories. Instead, just use --track when checking out a branch you intend to follow. And, more as an implementation detail than anything else, remember that the tracking is done through the above mentioned config options (which you can set/change using git-config or directly by editing the .git/config file). > >> $ git checkout --track origin/ReleaseCandidate > > That command does not work. It compains that --track can only be used > with -b, etc. > > I think > git checkout -b origin/ReleaseCandidate > > is the correct shortcut? > > git checkout -b ReleaseCandidate origin/ReleaseCandidate > > did work. I know that --track is automatic if the second argument is > remote. Maybe it's because I'm using a fairly recent version (1.6.2.1.307.g91408). tom