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

Re: question (possibly) on git subtree/submodules

From
Chris Packham <judge.packham@gmail.com>
Date
Jul 23, 2010, 16:56 UTC
Message-ID
<4C49C9C6.3080409@gmail.com>
In-Reply-To
<xotjlj92i9gr.fsf@leonardo.pit.corp.google.com>
Hi,
On 23/07/10 07:00, Maurizio Vitale wrote:
Show 25 quoted lines
> 
> I'm new to git and have read the recent thread on subtree support.
> I'm not sure they (or git submodules) offer what I'm looking for.
> Here's the scenario:
>        - I have a large monolithic code base, all in my repository (e.g.
>          I don't need to link in external repositories, which is what I
>          understand submodules offer
>        - I'd like to be able to clone only a small fraction of the
>          repository (say an arbitrary directory or even a single file)
>          in order to make small changes
>        - these directories are not known when the full repository is set
>          up.
>        - commits to the part I've checked out should show in the history
>          of any clone that includes the part, up to the full repository
>        - ideally, I should be able to incrementally clone portions (e.g.
>          I've checked out path/dir_A and realize I need to modify
>          path/dir_B as well).
>          these additional clones should be in whatever branch I switched
>          to after the initial checkouts.
> 
> Assuming the above makes any sense (in general or in git), is there
> anything in git that would help me doing what I'm looking for?
> Thanks,
> 
>         Maurizio 

The short answer is no. Nothing git has currently will let you clone a subset of files. Shallow clones exist if you want all the code and the last X changes. The reason for this is git, like other DVCSes, tracks _changes_ rather than _files_ this is something that took me a while to get my head around when I was learning git.

The best advice I've seen is to actually take your repository and use git filter-branch to create several smaller repositories (or depending on your desire for retention of history just create new repos). You can then use submodules or subtrees to stitch these back together into a super project to which you can add the smaller repositories as needed (note: I have never used subtrees so I'm not 100% sure if what I'm saying applies to them) .

We use this model with submodules at $dayjob and it works quite well for us.
Previous: Maurizio VitaleNext: Jonathan Nieder
Message 2 of 9 in “question (possibly) on git subtree/submodules”
  1. Maurizio VitaleJul 23, 2010
  2. Chris PackhamJul 23, 2010
  3. Jonathan NiederJul 23, 2010
  4. Chris PackhamJul 23, 2010
  5. AlexJul 27, 2010
  6. Jakub NarebskiJul 27, 2010
  7. RFC: Sparse checkout improvements (was: Re: question (possibly) on git subtree/submodules)Marc Branchaud, Jul 27, 2010
  8. skillzero@gmail.comJul 27, 2010
  9. Marc BranchaudJul 28, 2010

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.