Garbage Collection (Git)

Facts

  • It can be locally configured.
  • It can be triggered manually as well.
  • It cleans up not only orphaned commits.

Orphaned commits

When you are rebasing or resetting you will make some commits become orphaned.
(You can still see them via the git reflog.)


Configuration

You can configure the GC on you local machine. It will triggered with commands like pull, merge, rebase or commit.

git config gc.pruneExpire
Time until inaccessible objects will deleted.
(Default is 14 days)

git config gc.reflogExpireUnreachable
Time until inaccessible objects will be removed from the reflog.
(Default is 90 days)

git config gc.reflogExpire
Time until accessible objects will be removed from the reflog.
(Default is 30 days)