git gc
The Git housekeeping command that packs objects together and deletes unreachable objects old enough to be safe to remove.
In more detail
Git runs it automatically from time to time. Unreachable commits are kept for a grace period, two weeks by default, and reflog entries protect them longer, which is why lost work can usually be recovered.
Related terms
- reachable commit — A commit that can be found by starting from a branch, tag or HEAD and following parent links; commits that cannot are unreachable.
- reflog — Git's local record of every position HEAD and each branch has pointed at, used to find and recover commits that no branch points at any more.
Taught in
- Installing Git, And Telling It Who You Are — Advanced Git Internals & Distributed Workflows