Repository maintenance
Occasionally, you may need to do some cleanup of a repository, usually to make it more compact. Such cleanups are also a very important step after migrating a repository from another version control system.
Automatic housekeeping with git-gc
Modern Git (or, rather, all but ancient Git) from time to time runs the git gc --auto
command in each repository. This command checks whether there are too many loose objects (objects stored as separate files, with one file per object, rather than those stored together in a packfile; objects are almost always created loosely), and if so, then it launches the garbage collection operation. Garbage collection means gathering up all the loose objects and placing them in packfiles, as well as consolidating many small packfiles into one large packfile. Additionally, it packs references into the packed-refs
file. Objects that are unreachable even via reflog and are safely old are, by default, packed separately into a cruft...