Re: More help with "pull" please

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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: <refspec> lines for a
<repository>".  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.<name>.remote' and 'branch.<name>.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 <refspec> parameter takes default <refspec>s from Pull: lines, it merges only the first <refspec> found into the current branch, after
fetching all the remote refs."

Also, "When no refspec was given on the command line ... If
branch.<name>.merge configuration for the current branch <name> 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.<name>.remote and
branch.<name>.merge options; see git-config(1) for details."  That
agrees with the previous. If branch.<name>.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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux