git-count
Count git objects
TLDR
Print the total number of commits
Print the number of commits per contributor and the total number of commits
SYNOPSIS
git count-objects [--verbose] [-v] [-H] [--human-readable] [-h] [--disk-usage] [-d] [--no-reuse-delta]
PARAMETERS
--verbose, -v
Print detailed statistics.
-H, --human-readable
Print sizes in human readable format (e.g., 234 KiB, 2 MiB).
-d, --disk-usage
Only show the total disk usage. This is faster than the default mode.
--no-reuse-delta
Disable delta reuse during object counting.
DESCRIPTION
The `git count-objects` command is a plumbing command in Git used to count the number of unpacked objects, and their disk consumption. It's primarily used for debugging and understanding Git's internal storage. While typically not used in day-to-day operations, `git count-objects` offers insights into the size of your repository, allowing you to identify potential bloat and optimize storage if necessary. The output includes counts for loose objects, packfiles, and overall disk usage. It can be used to assess the effectiveness of garbage collection (`git gc`) and identify large objects that might be suitable for removal or optimization using tools like `git filter-branch` or `git lfs`. By default, the command operates on the current repository. This command provides an internal view of your git repository, and understanding its output requires some knowledge of git internals (loose objects, packfiles, indexes, etc.).
CAVEATS
This command provides an internal view of Git's object storage. Interpreting the output requires a good understanding of Git's internal structure. The results can vary based on the state of the repository (e.g., whether garbage collection has been recently run).
OUTPUT FORMAT
The command outputs a summary of object counts and sizes. Key fields include:
- `count`: Number of loose objects.
- `size`: Total size of loose objects.
- `in-pack`: Number of objects within packfiles.
- `size-pack`: Total size of packfiles.
- `prune-packable`: Number of objects that can be pruned from packfiles (duplicates).
- `garbage`: Number of garbage files (not associated with objects).
When using `-d`, only the total size is printed. When using `-v` the output is extended.
USE CASES
Common use cases include:
-Monitoring Repository Size: Tracking the overall size of the repository over time.
-Identifying Large Objects: Spotting unusually large objects that might be contributing to excessive repository size.
-Verifying Garbage Collection: Checking whether `git gc` has effectively reduced the number of loose objects and packfile size.
-Troubleshooting Performance Issues: Investigating whether a large number of objects is affecting Git's performance.
SEE ALSO
git gc(1), git fsck(1), git prune(1), git repack(1)