git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: More help with "pull" please

From
Tomas Carnecky <tom@dbservice.com>
Date
Apr 1, 2009, 23:14 UTC
Message-ID
<F364AB31-EC5B-4719-834E-58613BDBC433@dbservice.com>
In-Reply-To
<450196A1AAAE4B42A00A8B27A59278E70A7D4E71@EXCHANGE.trad.tradestation.com>
On Apr 2, 2009, at 12:53 AM, John Dlugosz wrote:
Show 21 quoted lines
>> 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).

Show 31 quoted lines
>>
>> $ 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).

Show 15 quoted lines
>
>> $ 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
Previous: John DlugoszNext: John Dlugosz
Message 4 of 8 in “More help with "pull" please”
  1. John DlugoszApr 1, 2009
  2. Tomas CarneckyApr 1, 2009
  3. John DlugoszApr 1, 2009
  4. Tomas CarneckyApr 1, 2009
  5. John DlugoszApr 1, 2009
  6. Junio C HamanoApr 2, 2009
  7. John DlugoszApr 2, 2009
  8. Tomas CarneckyApr 2, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.