View the Total Size of the Current Git Repository
What Do You Want to Confirm
| What to Confirm | Recommended Command | Notes |
|---|---|---|
How large is the .git directory itself | du -sh .git | See disk usage of Git history, objects, index, and refs |
| How large is the entire repository | du -sh . | Includes working directory files and .git |
| Detailed Git object store statistics | git count-objects -vH | See unpacked objects, pack files, and object store size |
Recommended Commands
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
.gitandsize-packfirst. - 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
duis a common Linux command; this page assumes a Linux environment.git count-objects -vHcan'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
.githistory that has grown, then decide whether to clean build directories, migrate large files, or tidy up history.