Skip to content
Foxipa
Code Completion 4 Challenges

Complete the Git commands: Git prune: Remove Unreachable Objects Safely

In a disposable repository, create a commit on a temporary branch, delete that branch, and expire the test repository's reflogs so the commit becomes genuinely unreachable for the experiment. Use `git fsck --unreachable --no-reflogs` to identify the unreachable commit and supporting objects. Run `git prune -n -v --expire=now` and record the candidates without changing the repository. Confirm the unreachable commit still exists. Then run `git prune --expire=now` and verify that the commit can no longer be resolved as an object. Repeat the experiment with an additional `<head>` pointing to the temporary commit and prove with a dry run that objects reachable from that head are protected. Finally explain why the same operation would be risky in a real repository and why `git gc` is normally preferred for routine maintenance. This lesson uses only official Git project documentation for command semantics: `git-prune`, the Git 2.56.0 command index, and the official `git-fsck` and `git-gc` documentation for command boundaries. No third-party Git documentation is used for command semantics.

Advanced ~6 min read

Challenge 1

Complete the Git command to inspect or remove unreachable objects.

bash Your answer
git  -n -v --expire=now

Press Ctrl⌘Enter to check your answer

Challenge 2

Complete the Git command to inspect or remove unreachable objects.

bash Your answer
git  --expire=now

Press Ctrl⌘Enter to check your answer

Challenge 3

Complete the Git command to inspect or remove unreachable objects.

bash Your answer
git  -n -v --expire=never

Press Ctrl⌘Enter to check your answer

Challenge 4

Complete the Git command to inspect or remove unreachable objects.

bash Your answer
git  -n -v --progress --expire=now

Press Ctrl⌘Enter to check your answer