Skip to main content

View the Total Size of the Current Git Repository

What Do You Want to Confirm

What to ConfirmRecommended CommandNotes
How large is the .git directory itselfdu -sh .gitSee disk usage of Git history, objects, index, and refs
How large is the entire repositorydu -sh .Includes working directory files and .git
Detailed Git object store statisticsgit count-objects -vHSee unpacked objects, pack files, and object store size

View .git Directory Size

du -sh .git

View Entire Repository Size

du -sh .

View Git Object Store Statistics

git count-objects -vH

How to Read the Output

Key fields from git count-objects -vH:

  • count: Number of currently unpacked objects.
  • size: Space occupied by these unpacked objects.
  • in-pack: Number of objects already packed into pack files.
  • packs: Number of pack files.
  • size-pack: Total size of pack files -- usually the best indicator of history object store size.

This command only counts Git object store data, not the entire working directory; du -sh . gives you "how large the entire repository is on disk."

Common Combinations

du -sh .git
du -sh .git/objects
git count-objects -vH
  • To diagnose whether historical objects have bloated, check .git and size-pack first.
  • To diagnose whether dependency directories, datasets, or build artifacts are taking up space, check the entire repository with du -sh ..
  • If the repository uses Git LFS, you can also check separately:
du -sh .git/lfs/objects

Notes

  • du is a common Linux command; this page assumes a Linux environment.
  • git count-objects -vH can't see large files in the working directory or build artifacts that exist on disk but are listed in .gitignore.
  • If the repository size grows abnormally, first determine whether it's the working directory or .git history that has grown, then decide whether to clean build directories, migrate large files, or tidy up history.