my-git

Microsoft Scalar and Large Repository Git Practice

English 中文

Original links:

1. The Real Problems of Large Repositories

As a repository grows larger, what developers notice first is typically:

The story of Microsoft Scalar illustrates that optimizing large repositories cannot rely solely on “getting a faster computer”; it requires combining multiple Git capabilities.

2. The Windows Repository Case

Microsoft publicly shared the extreme scale of the Windows team after migrating to Git: millions of files, a repository in the hundreds of gigabytes, thousands of engineers, and a massive daily volume of PRs, builds, and Reviews.

The inspiration from this case is that enterprise-level Git problems often do not lie in Git’s version control semantics, but in the costs of these foundational operations:

Therefore, Microsoft’s evolutionary path from VFS for Git to Scalar centers on keeping Git usable under massive repositories.

3. Core Ideas of Scalar

Scalar combines multiple configurations suitable for large repositories:

For regular teams, the focus is to understand why these capabilities need to be used together, without necessarily requiring everyone to use Scalar right away.

4. Partial clone

Partial clone is useful for reducing the data downloaded during the initial clone and subsequent fetches.

Common approach:

git clone --filter=blob:none <url>

This kind of blobless clone downloads commits and trees first, downloading blob content on demand when needed.

Suitable for:

Note:

5. Shallow clone

Shallow clone pulls only a portion of the commit history:

git clone --depth 1 <url>

Suitable for:

Not suitable for:

6. Sparse checkout

Sparse checkout keeps only a portion of the directories in the working area:

git sparse-checkout init --cone
git sparse-checkout set service-a service-b

Suitable for:

In Microsoft Scalar’s experience, cone mode sparse checkout is a critical optimization direction, because selecting by directory yields more stable performance than arbitrary patterns.

7. Adoption Sequence for Large Repository Teams

Recommended sequence:

  1. Identify where the repository is slow first; look at clone, fetch, status, and checkout separately
  2. CI uses shallow clone or treeless/blobless clone for targeted optimization
  3. Developer workspaces prioritize trying blobless partial clone
  4. Enable sparse checkout in Monorepos, defining directory sets by team or service
  5. Enable repository maintenance capabilities, such as git maintenance
  6. Clean up large files and generated artifacts that shouldn’t enter Git

8. Key Takeaways

Large repository optimization must avoid single-point thinking:

These capabilities need to be combined to form truly actionable large repository practices.