Git Refs, Reachability and Garbage Collection
Names and graph edges
A branch ref normally points to a commit; symbolic HEAD usually points to the current branch name. Objects reachable from selected roots can be found by following commit parents, trees, tree entries and tag targets. Removing one ref does not necessarily make an object unreachable, because other refs, reflogs or the index may retain it.
Inspect roots and reachability
The fixture contains a detached experiment whose commit is no longer on a branch. Its HEAD reflog still records it. rev-list --all --objects walks ordinary refs and HEAD; it is not a list of every object on disk. fsck normally also considers reflogs and the index as roots, unless options change that choice.
git show-refgit rev-list --all --objectsgit fsck --no-reflogs --unreachableRecovery and maintenance
An unreachable object may still exist in loose or packed storage. A dangling object is an object not directly used by another object in the relevant analysis; not every unreachable object is reported as dangling. Garbage collection can expire reflogs, repack and remove eligible unreachable objects. Timing is configurable, and neither reflog nor an object ID guarantees recoverability. Preserve valuable work and independent backups before maintenance.
Practice and check
Use the fixture’s verified experiment ID to inspect the commit and anchor it with a rescue branch. Predict the difference between fsck before and after the rescue. The automated lab verifies the graph and object availability; it deliberately does not run gc, prune or reflog expiration. Do not use fsck --lost-found unless you intend to write recovery files.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Git Refs, Reachability and Garbage Collection — knowledge check
Reason about Git objects, index and reference state.
Which can keep objects available after branch removal?
What does rev-list --all --objects enumerate?
Does unreachable always mean deleted?
Which action anchors a verified lost commit?
What did the lab deliberately avoid?