LinuxCommandLibrary

git-count-objects

Verify Git repository integrity and disk usage

TLDR

Count all objects and display the total disk usage

$ git count-objects
copy

Display a count of all objects and their total disk usage, displaying sizes in human-readable units
$ git count-objects [[-H|--human-readable]]
copy

Display more verbose information
$ git count-objects [[-v|--verbose]]
copy

Display more verbose information, displaying sizes in human-readable units
$ git count-objects [[-H|--human-readable]] [[-v|--verbose]]
copy

SYNOPSIS

git count-objects [-v | --verbose] [-H | --human-readable]

PARAMETERS

-v, --verbose
    Report the number of loose objects found and their total disk usage. Without this option, only the total disk usage is printed.

-H, --human-readable
    Display disk usage in human-readable units (e.g., KB, MB, GB). This option implies --verbose if --verbose is not specified.

DESCRIPTION

git count-objects is a Git plumbing command used to report the number and disk consumption of loose objects in the repository's object database. It specifically counts objects that are not yet packed into packfiles. This command is helpful for understanding the state of your repository's object storage and can indicate whether a garbage collection (git gc) might be beneficial to optimize disk space. By default, it outputs the total size of loose objects in bytes. The command does not process objects stored within pack files, focusing solely on the individual files residing directly in the .git/objects directory. It's a quick way to assess the "unpacked" overhead.

CAVEATS

This command only counts loose objects (individual files in .git/objects). It does not count objects that are already stored inside pack files. The reported disk usage might slightly differ from direct file system tools like du due to variations in file system block allocation or sparse file handling.

HISTORY

git-count-objects has been a part of Git since its early days, serving as a fundamental plumbing command to inspect the object database. Its purpose has remained consistent: to provide a quick overview of the loose object store, aiding in repository maintenance and optimization efforts, particularly in conjunction with garbage collection routines.

SEE ALSO

git gc(1), git repack(1), git verify-pack(1), git fsck(1), git prune(1)

Copied to clipboard