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

Re: master and origin

From
Jakub Narebski <jnareb@gmail.com>
Date
Oct 29, 2006, 21:40 UTC
Message-ID
<200610292240.57443.jnareb@gmail.com>
In-Reply-To
<4d8e3fd30610291329n7fe59873r87cbee9ccbd4b720@mail.gmail.com>
Paolo Ciarrocchi wrote:
> On 10/29/06, Jakub Narebski <jnareb@gmail.com> wrote:
[...]
Show 13 quoted lines
>> pull = fetch + merge, so if you pull when you are on your local 'master'
>> branch (and 'master' branch is first in the .git/remotes/origin file I think)
>> you would fetch remote 'master' into local 'origin' and merge what you
>> have in 'origin' into your 'master' (or merge remote 'master' into
>> your local 'master' if you want to think like that).
> 
> So in this case, there is a difference between doing my local
> development under master or myownlocalbranch. Right?
> I mean, if I do my own development under master and I pull, the master
> branch will include origin and my local changes. Corret?
> While if I work in my local branch the datas are not modified with a
> pull, because pull will update only the local copy of the remote
> branch. Correct?

To be more exact (sorry for the confusion) "git pull" means first do the "git fetch", i.e. update local 'tracking' branches with the contents of remote branches. For ordinary clone this means:

    remote (origin)  | local
   ------------------+------------------
    master           | origin
    next             | next
    ...              | ...
For --use-separate-remote this means
   remote (origin)   | local
  -------------------+-------------------
   master            | refs/remotes/origin/master
   next              | refs/remotes/origin/next
   ...               | ...

Then it does "merge". It takes the remote branch from first Pull: line in remotes/origin file, or first in remote.origin.fetch configuration variable, and merges it with _current_ branch.

So if you always work on local branches, and newer want to merge automatically, you probably should use "git fetch" for fetching changes.

What is not obvious (and is PITA for first-timers) that to merge
some <sidebranch> into your <branch>, it is simplest to first switch
to <branch> using
  git checkout <branch>
and then merge <sidebranch> using
  git pull . <sidebranch>
(where '.' means local repository).
HTH
-- 
Jakub Narebski
Previous: Paolo CiarrocchiNext: Luben Tuikov
Message 6 of 7 in “master and origin”
  1. Paolo CiarrocchiOct 29, 2006
  2. Jakub NarebskiOct 29, 2006
  3. Luben TuikovOct 29, 2006
  4. Jakub NarebskiOct 29, 2006
  5. Paolo CiarrocchiOct 29, 2006
  6. Jakub NarebskiOct 29, 2006
  7. Luben TuikovOct 29, 2006

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.