What does `git gc` do, and when does it run automatically?
IntermediateConceptGit internals: objects, refs and the index
Answer
It packs loose objects, packs refs, prunes unreachable objects older than gc.pruneExpire (2 weeks), and expires old reflog entries. git gc --auto runs after commands like commit and merge once there are more than about 6700 loose objects or 50 packs. Large teams usually switch to git maintenance for scheduled background tasks.
git maintenance start
git gc --prune=now --aggressive # rarely needed
More on Git internals: objects, refs and the index
What are the four object types in Git's object database?BeginnerIs Git a snapshot system or a diff system?BeginnerWhat is the SHA-1 (or SHA-256) hash of an object and how is it computed?BeginnerWhere does Git store objects on disk, and what are loose objects versus packfiles?IntermediateWhat exactly is a branch, and what does creating one cost?IntermediateWhat is HEAD?Beginner