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

Taught in

References