---
title: "Scaling Git’s garbage collection"
description: "Git's garbage collection historically stored recently-written unreachable objects as individual loose files so their mtimes could govern expiry, which bloated storage, exhausted inodes and slowed repacks in busy repositories at GitHub's 18.6 PB scale."
url: "https://swe.quest/articles/scaling-git-s-garbage-collection-9458d212eaaeddf6"
canonical: "https://github.blog/engineering/architecture-optimization/scaling-gits-garbage-collection/"
source: "GitHub Engineering"
published: "2022-09-13"
difficulty: "hard"
kind: "Deep dive"
reading_minutes: 23
tags: ["version-control","storage-engines","memory-management","scalability"]
---

# Scaling Git’s garbage collection

A post on [GitHub Engineering](https://swe.quest/sources/github.md), published 2022-09-13, 23 min read, Deep dive. Original: [https://github.blog/engineering/architecture-optimization/scaling-gits-garbage-collection/](https://github.blog/engineering/architecture-optimization/scaling-gits-garbage-collection/)

## Summary

Git's garbage collection historically stored recently-written unreachable objects as individual loose files so their mtimes could govern expiry, which bloated storage, exhausted inodes and slowed repacks in busy repositories at GitHub's 18.6 PB scale. Cruft packs fix this by packing unreachable objects together with a companion .mtimes file holding a 4-byte per-object timestamp, indexed via the pack index, so individual objects can be freshened and expired independently. The --prune=\<date\> grace period exists to mitigate a race where a concurrent push makes a to-be-deleted object reachable, and cruft pack generation walks reachability to separate reachable from unreachable objects while expiring unreachable clusters all-or-nothing. The work was contributed upstream to Git.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Version control](https://swe.quest/tags/version-control.md) (Engineering practices)
- [Storage engines](https://swe.quest/tags/storage-engines.md) (Data & databases)
- [Memory management](https://swe.quest/tags/memory-management.md) (Compilers & runtimes)
- [Scaling](https://swe.quest/tags/scalability.md) (Distributed systems)

## Prerequisites

- Git object model
- Git packfiles and pack indexes
- Git reachability and references

## Keywords

Git, cruft packs, git gc, packfiles, multi-pack index, commit-graph, GitHub

## Related posts

- [20× the CI traffic without getting slower: How we rebuilt Git serving at Datadog](https://swe.quest/articles/20-the-ci-traffic-without-getting-slower-how-we-rebuilt-git-serving-at-datadog-9f7156670a81ca53.md): Datadog Engineering · 2026-08-19 · Medium · 13 min read · Version control, CI/CD, Scaling, Caching, Replication
  Datadog replaced CI fetches from a replicated Gitaly/Praefect cluster with gitretriever, a fleet of independent Git mirrors that poll GitHub per changed ref and fan packfiles out to autoscaled relays over a gRPC signaling stream plus HTTP.
- [Inside GitHub’s new Git storage architecture](https://swe.quest/articles/inside-github-s-new-git-storage-architecture-014a8644555e81c8.md): GitHub Engineering · 2026-11-05 · Hard · 15 min read · Version control, Storage systems, Distributed systems, Scaling, Replication
  GitHub's new Git storage architecture, Rubicon, rests on one observation: only reference updates need ordering.
- [Scaling Git at OpenAI](https://swe.quest/articles/scaling-git-at-openai-cd141be9cdce804b.md): OpenAI · 2026-11-02 · Hard · 24 min read · Version control, Distributed systems, Consistency models, Scaling, Storage systems
  Pando is OpenAI's new Git backend for its monorepo, built to handle the concurrent pushes and fetches generated by Codex-driven parallel development while staying fully compatible with the Git protocol and client.
- [Automating dead code cleanup](https://swe.quest/articles/automating-dead-code-cleanup-e03bc4ba07b5bf1c.md): Meta Engineering · 2023-10-24 · Medium · 7 min read · Static analysis, Refactoring & migrations, Developer productivity, Python
  Meta's SCARF framework finds dead code by building a cross-language, symbol-level dependency graph from Glean and augmenting it with runtime usage data such as API endpoint logs, URI dispatch tables and async job invocations, then garbage-collects unreachable nodes, subgraphs and cycles.
- [Improve Git monorepo performance with a file system monitor](https://swe.quest/articles/improve-git-monorepo-performance-with-a-file-system-monitor-1e7445f19bf20b0e.md): GitHub Engineering · 2022-06-29 · Medium · 22 min read · Version control, Performance engineering, Developer tools
  Git 2.37.0 adds a builtin file system monitor daemon (\`git fsmonitor--daemon\`) for macOS and Windows, enabled by setting \`core.fsmonitor\` to true.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
