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

Re: Monotone workflow compared to Git workflow ( was RE: Git vs Monotone)

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Jul 31, 2008, 21:13 UTC
Message-ID
<alpine.LFD.1.10.0807311357430.3277@nehalem.linux-foundation.org>
In-Reply-To
<20080731205400.GA7911@atjola.homenet>
On Thu, 31 Jul 2008, Björn Steinbrink wrote:
Show 8 quoted lines
> > 
> > So literally, if you do
> > 
> > 	git clone <cntral-repo-over-network> <local>
> 
> Hum, I guess I'm just missing something and prepare to get flamed, but
> wouldn't you want that one to be bare? Otherwise, the other clones won't
> see all of the original repo's branches, right?

Making it bare might be a good idea for other reasons too (it makes it much more obvious that it's a "local clone" and is somehow special). But it's really a matter of taste - and the project - exactly how you do it.

For example, the kernel only has a single master branch in the top repo, so there it really doesn't matter, and yes, I'm more kernel-oriented than anything else, of course.

But I don't think it's exactly wrong to have the initial clone be a real repository that you do work in. Quite often the history really is the _bulk_ of the database by far (at least with projects that have big enough repositories for this to even matter in the first place!), and as long as you just download that once and share that thing, you're already ahead of the game and the rest is really just details.

Show 9 quoted lines
> Maybe even better:
> 
> mkdir local-mirror
> cd local-mirror
> git --bare init
> git remote add -f --mirror origin <central-repo-over-network>
> 
> A cronjob (or whatever) could keep the local mirror up-to-date and the
> other repos can fetch from there.

Heh. You can certainly do it many ways. I suspect the _easiest_ model is actually to do one single local repo that is special (and perhaps bare), and then you can clone all the other ones with

	git clone --reference <local-reference> <remote> <new-local>

because that will automatically set up the new local repo to have the local reference as an alternates thing, and will avoid downloading unnecessary stuff.

So my point about the eleven repos was not that it's the best way to do one remote clone and then eleven local ones - my point was that even if you do that _stupid_ thing, you'd have seen sharing without even knowing what you really did.

If you want to explicitly share, I think the local bare reference and using "git clone --reference" is the best way. It sets up a special link-file (it's just a text-file that git knows about, so it should work fine under Windows too - no need for filesystem support) in .git/objects/info/alternates.

IOW, git-clone --reference works like "git clone -s", but does so with one special local database, while allowing you to clone from anywhere. Very convenient.

And no, I don't think we document all these "tricks" very well. Partly because people are _already_ complaining about how git can do so many things ;) But partly because if you don't know what you're doing, the "tricks" are often things you really need to understand, and can be a bit dangerous otherwise.

For example, the "git clone -s" (or --reference) thing is *very* useful, but one result of other repositories then sharing a database with the reference one is that suddenly the reference repo is very special. You must not remove it (obviously!), but you also must not rebase it and prune it etc.

So all the normal git workflows are at least designed to be _safe_ even in the absense of people not knowing what they are doing. The duplication may be using harddisk space, but

 - quite often the checkout is actually an even bigger issue, and the git 
   repo is small enough that lots of people don't really worry.
 - duplicating the repo also means that you cannot _possibly_ screw up 
   other people/repos and does give you a kind of backup (even if 
   same-disk backups are obviously of dubious use: they shouldn't be your 
   _primary_ backup, but having multiple copies on a single disk still 
   protects against a _lot_ of problems)
so... It's a trade-off.
			Linus
Previous: Avery PennarunNext: Martin Langhoff
Message 23 of 33 in “Git vs Monotone”
  1. Sverre RabbelierJul 31, 2008
  2. Stephen R. van den BergJul 31, 2008
  3. Petr BaudisJul 31, 2008
  4. Jeff KingJul 31, 2008
  5. Craig L. ChingJul 31, 2008
  6. Sverre RabbelierJul 31, 2008
  7. Jeff KingJul 31, 2008
  8. Linus TorvaldsJul 31, 2008
  9. Craig L. ChingJul 31, 2008
  10. Linus TorvaldsJul 31, 2008
  11. Junio C HamanoJul 31, 2008
  12. Linus TorvaldsJul 31, 2008
  13. Felipe ContrerasAug 23, 2008
  14. Blum, RobertJul 31, 2008
  15. Robin RosenbergAug 10, 2008
  16. David KastrupAug 1, 2008
  17. Monotone workflow compared to Git workflow ( was RE: Git vs Monotone)Craig L. Ching, Jul 31, 2008
  18. Linus TorvaldsJul 31, 2008
  19. Shawn O. PearceJul 31, 2008
  20. Craig L. ChingJul 31, 2008
  21. Björn SteinbrinkJul 31, 2008
  22. Avery PennarunJul 31, 2008
  23. Linus TorvaldsJul 31, 2008
  24. Martin LanghoffJul 31, 2008
  25. Linus TorvaldsJul 31, 2008
  26. Dmitry TorokhovAug 1, 2008
  27. Linus TorvaldsAug 1, 2008
  28. Linus TorvaldsAug 1, 2008
  29. Sean EstabrooksJul 31, 2008
  30. Theodore TsoJul 31, 2008
  31. Theodore TsoJul 31, 2008
  32. Sverre RabbelierAug 1, 2008
  33. Daniel BarkalowAug 1, 2008

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.