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

Re: basics... when reading docs doesn't help

From
GLGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Date
Mar 30, 2007, 19:49 UTC
Message-ID
<Pine.LNX.4.60.0703302135590.10784@poirot.grange>
In-Reply-To
<Pine.LNX.4.64.0703301126390.6730@woody.linux-foundation.org>
On Fri, 30 Mar 2007, Linus Torvalds wrote:
Show 64 quoted lines
> 
> You need to mark "refs/heads/origin" as always following the remote 
> "master", even if it gets re-based.  You do that by adding a "+" before 
> the refspec that describes the remote.
> 
> These days, with git-1.5.x, "git clone" will do that for you (and make the 
> remotes fall under "refs/remotes/origin/*" instead - they're considered 
> separate branches from the local branches these days). However, since you 
> created the repository with an older git version, it still uses the 
> original format (and even though you upgraded your git binary, it will use 
> the old-fashioned branch format for remote branches and for 
> configuration).
> 
> So in your case, the remote is probably described by the 
> .git/remotes/origin file, and it looks something like
> 
> 	URL: git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc
> 	Pull: master:origin
> 
> and you should just change that "Pull:" line to have a "+" in front of the 
> refspec:
> 
> 	URL: git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc
> 	Pull: +master:origin
> 
> which tells git that the remote "master" branch should now 
> *unconditionally* be followed into the local "origin" branch when you 
> pull.
> 
> (In a more modern setup, you wouldn't have a .git/remotes/origin file at 
> all, insead you would have something like this in the .git/config file:
> 
> 	[remote "origin"]
> 		url = git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc
> 		fetch = +refs/heads/*:refs/remotes/origin/*
> 
> 	[branch "master"]
> 		remote = origin
> 		merge = refs/heads/master
> 
> which means that there is a remote called "origin", and all of the remote 
> heads in that remote ("refs/heads/*") will be fetched into the local 
> repository under "refs/remotes/origin/*". And the "+" again means that we 
> do this even if it's not a fast-forward, ie we trust the remote 
> explicitly.
> 
> So "git fetch origin" will fetch *all* branches from "origin" into your 
> local repository, but to distinguish them from your *own* branches, they 
> will be under .git/refs/remotes/ instead of your "real" local branches 
> that are in ".git/refs/heads/. So you can now see the difference between 
> your *local* version of a branch X and the remote version of that same 
> branch by using "X" and "remotes/origin/X" respectively to describe that 
> branch.
> 
> Then, the second part of the above config file means that when you're on 
> the local "master" branch and do a "git pull", it will fetch it from the 
> remote "origin", and merge the remote "refs/heads/master" branch from that 
> remote (the same one that will be fetched into refs/remotes/origin/master 
> by a "git fetch".
> 
> Yeah, this is all a bit complex, and it takes a while to wrap your head 
> around it, but I have to say, once you do, the git-1.5.x layout really 
> *is* very powerful, and it's actually very natural too (but the "very 
> natural" part only comes after you have that "Aaahh!" moment!)

Aha, so, that's how it is then! Why hasn't anybody explained this to me strait away?!:-))))

Yeah, hopefully, I'll learn to at least use this thing efficiently enough. Someone has to write a book on it though...

And, so, it's a pity I cloned Paul's tree yesterday with the "old" git. And from your answer above it seems like some features of the "new" git will not be available with this tree, like equally named local and remote branches, etc. There isn't a way to convert such a "old style" tree to the "new style", is there? Not a big deal, will re-clone at some point, maybe when we get local git mirrors...

Many thanks for taking your time to answer, Linus! Guennadi --- Guennadi Liakhovetski

Previous: Linus TorvaldsNext: Linus Torvalds
Message 9 of 18 in “basics... when reading docs doesn't help”
  1. Guennadi LiakhovetskiMar 29, 2007
  2. J. Bruce FieldsMar 29, 2007
  3. Junio C HamanoMar 29, 2007
  4. J. Bruce FieldsMar 29, 2007
  5. Guennadi LiakhovetskiMar 29, 2007
  6. Linus TorvaldsMar 29, 2007
  7. Guennadi LiakhovetskiMar 30, 2007
  8. Linus TorvaldsMar 30, 2007
  9. Guennadi LiakhovetskiMar 30, 2007
  10. Linus TorvaldsMar 30, 2007
  11. Theodore TsoMar 30, 2007
  12. Junio C HamanoMar 30, 2007
  13. Guennadi LiakhovetskiMar 30, 2007
  14. Theodore TsoMar 30, 2007
  15. J. Bruce FieldsMar 30, 2007
  16. Andreas HerrmannMar 30, 2007
  17. Guennadi LiakhovetskiMar 30, 2007
  18. Matthieu MoyMar 29, 2007

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.