GitHub - mohsen1/git-lazy-mount: Lazily mount a git repo without cloning it. Works with ordinary git commands

2 min read Original article ↗

Lazily mount a git repo without cloning it. Files materialize as they are read or edited.

git lazy-mount https://github.com/example/huge-repo ~/huge-repo

After it returns, your ordinary git and tools just work:

cd ~/huge-repo
vim src/main.rs
git commit -am 'Some edit'
git switch -c feature
git push

Why?

This is aimed at microVMs that spin up to run coding agents against a git repository. The idea is that the coding agent can start working immediately without having to wait for a full clone.

When the agent runs a test or build, only relevant files are downloaded on demand.

Grep tool in AI session

Tools like rg and git grep read every file, so they pull the whole repo and undo the point of lazy-mount.

To mititgate this, we can route search through sgrep instead. It queries a code-search index (Sourcegraph by default, and pluggable) and overlays your uncommitted edits, fetching nothing.

More in crates/sgrep.

Performance in real world

Across 20 repositoriesfacebook/react to the 179k-file LLVM tree — git clone --depth 1 totals 7.3 GB vs 1.3 GB of lazy mounts (5.5× less). Ready time is 268.7 s for shallow clone vs 88.7 s for lazy-mount (3.0× faster), and each lazy mount is ready in 0.8–15.1 s (measured in Firecracker microVMs):

Disk to work on each repo: shallow git clone vs git lazy-mount

Lazy mounts keep full history even when the clone baseline is shallow, are ready in seconds, and materialize only the files you touch. In the full Firecracker agent benchmark, lazy-mount won 19 of 20 code-search/edit/commit tasks: full clone+agent totaled 3394.2 s vs 1322.7 s for lazy mount+agent (2.57× faster), with the only loss on the tiny vue repo. Full data, time/disk charts, and the session-time breakdown: benchmarks/.

Linux Only

Linux only: because almost all microVMs are Linux-based.

The whole stack (a transparent kernel-mounted working tree) is built on Linux FUSE (libfuse3, /dev/fuse).

Windows and macOS

Windows and macOS are not supported. The design notes and feasibility studies are kept under docs/future-platforms/ if we pick them up later.

Install / build

# Linux. Needs libfuse3 + the system git (>= 2.36).
cargo build --release -p glm-cli --features fuse   # produces `git-lazy-mount`

Docs

Everything is in docs/:

License

MIT + Apache