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

Re: git branch performance problem?

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Oct 11, 2007, 15:16 UTC
Message-ID
<alpine.LFD.0.999.0710110807170.20690@woody.linux-foundation.org>
In-Reply-To
<f329bf540710101926vedf8b19p52e3eeb193203d03@mail.gmail.com>
On Wed, 10 Oct 2007, Han-Wen Nienhuys wrote:
> 
> I recall reading a few months ago that it was "clone -l" that gave you
> the jeebies, rather than "clone -s".

Yes, "clone -l" gives me the jeebies, because I'm a totally anal person when it comes to disk corruption and a worry-wart. I've just had it happen too many times (usually because a disk simply goes bad), and "git clone -l" basically means that if one repository gets corrupted, then so does the other one.

But clone -s gives me even *more* jeebies, although I think it's in some respect also more useful. The alternates thing is really useful for servers in particular, where you basically want to have multiple "branches" maintained by lots of people, but all based on some expected base version.

So if you think of alternates as a "kernel.org" or "repo.or.cz" thing, where you might have a hundred different repositories all based on the same "standard" version, then I think you basically have the right model. In that situation, "git clone -l" doesn't work that well, since the repositories just start out sharing data, but don't do it long term.

So "git clone -l" (which is the default now - my jeebies really are my personal psychological problem) is really useful for latency reasons for a local clone, and has basically no real downsides. It's not useful for *backups*, but it's useful for development.

Show 5 quoted lines
> > So the rule really is: never *ever* do anything but fast-forward in a repo
> >[..]
> 
> Methinks this is all too difficult. I will use clone -l henceforth. Is
> there any reason to prefer -s over -l?

Good. And no, for actual *development* there is no reason to prefer -s over -l (and as mentioned, '-l' is the default in modern versions).

For a git *server* setup, -s is better, since it's more long-term. But in that situation, it also requires that the server maintainer have some rules (ie only use "-s" for stable base trees and/or use extra care when repacking the base).

> Given your lengthy exposition on the dangers of alternates, I would say 
> this is a features that deserves to be buried or at least deemphasized 
> in the documentation.
I do agree. We should make the dangers very clear.
> For cherrypicking convenience, I would still appreciate it if there
> was a mechanism similar to alternates that would allow me to view
> objects from an alternate repo; objects found through this mechanism
> should never be assumed to be present in the database, of course.

Well, the way that really should work is that you "git fetch remote" and work on the end result in a "remote branch".

That *will* make the objects present in the database, but not in your actual branches (until you cherry-pick), but there really are no real downsides. If the remote is truly related to your local tree, it all delta's so well that the disk space issues should basically be none.

		Linus
Previous: Han-Wen NienhuysNext: Salikh Zakirov
Message 20 of 25 in “git branch performance problem?”
  1. Han-Wen NienhuysOct 10, 2007
  2. Lars HjemliOct 10, 2007
  3. Han-Wen NienhuysOct 10, 2007
  4. Han-Wen NienhuysOct 10, 2007
  5. Han-Wen NienhuysOct 10, 2007
  6. J. Bruce FieldsOct 10, 2007
  7. Lars HjemliOct 10, 2007
  8. Han-Wen NienhuysOct 10, 2007
  9. J. Bruce FieldsOct 10, 2007
  10. Han-Wen NienhuysOct 10, 2007
  11. Johannes SchindelinOct 10, 2007
  12. Brandon CaseyOct 10, 2007
  13. Mike RalphsonOct 11, 2007
  14. Johannes SchindelinOct 11, 2007
  15. Linus TorvaldsOct 10, 2007
  16. Han-Wen NienhuysOct 11, 2007
  17. Alex RiesenOct 11, 2007
  18. Johannes SchindelinOct 11, 2007
  19. Han-Wen NienhuysOct 11, 2007
  20. Linus TorvaldsOct 11, 2007
  21. Salikh ZakirovOct 12, 2007
  22. Lars HjemliOct 10, 2007
  23. git-branch: only traverse the requested refsLars Hjemli, Oct 10, 2007
  24. Johannes SchindelinOct 10, 2007
  25. Lars HjemliOct 10, 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.