Skip to content
Foxipa
Code Completion 4 Challenges

Complete the Git commands: Git Safe Recovery Laboratories: ORIG_HEAD, Backup References, and Abortable Operations

Run all four laboratories in disposable repositories. For Lab 1, record the original `HEAD`, perform a hard reset to an earlier commit, prove that `ORIG_HEAD` names the original tip, and recover to it. For Lab 2, create a named safety branch before moving `HEAD`, then use that reference to recover. For Lab 3, construct a real conflicting revert, inspect the in-progress state, and use `git revert --abort`; verify that `HEAD`, tracked files, and status return to their pre-sequence values. For Lab 4, write a short recovery record naming the state that changed, the recovery anchor, the command used, and the post-recovery evidence. Success requires state evidence, not just a zero exit status. For every laboratory, capture the commit IDs before and after the destructive or abortable operation, verify working-tree and index state, and explain why the chosen recovery anchor was valid for that specific operation.

Intermediate ~6 min read

Challenge 1

Complete the Git command to record a history-preserving reversal.

bash Your answer
git  --abort

Press Ctrl⌘Enter to check your answer

Challenge 2

Complete the Git command to record a history-preserving reversal.

bash Your answer
git 

Press Ctrl⌘Enter to check your answer

Challenge 3

Complete the Git command to record a history-preserving reversal.

bash Your answer
git  <commit-that-conflicts>

Press Ctrl⌘Enter to check your answer

Challenge 4

Complete the Git command to resolve or verify a revision.

bash Your answer
git  HEAD

Press Ctrl⌘Enter to check your answer