Skip to content

Support fetching only a specific directory in a Git repository #23012

@alexrp

Description

@alexrp

With a recent Git, if I want to clone only a specific directory of a repo with minimal fluff, I can do something like:

$ mkdir zig
$ cd zig
$ git init
$ git remote add origin https://github.com/ziglang/zig.git
$ git fetch --depth 1 --filter=tree:0 origin bedf806672d9e00203f9942c62887b271d12eb7f
$ git sparse-checkout init --no-cone
$ git sparse-checkout set /src
$ git checkout bedf806672d9e00203f9942c62887b271d12eb7f

(The resulting repo is only 24M; a regular clone is 535M.)

It seems to me that it would be useful for the package manager to support some moral equivalent of this. I'm thinking, in particular, of making it less wasteful to depend on a library that lives in a monorepo.

I'm not sure what the url syntax should look like, though; ideas welcome. Maybe something like git+https://github.com/ziglang/zig.git#bedf806672d9e00203f9942c62887b271d12eb7f@src?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSolving this issue will likely involve adding new logic or components to the codebase.zig build systemstd.Build, the build runner, `zig build` subcommand, package management

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions