Skip to content
Foxipa
Code Completion 4 Challenges

Complete the Git commands: Git Revert: Recording a History-Preserving Reversal

Create a disposable repository with at least three commits whose effects are easy to distinguish. Revert the newest commit, then inspect the resulting history and patch. In a separate disposable repository, revert an earlier commit while preserving a later commit. Finally, construct a controlled conflict during a revert, resolve it, and complete the operation. Record the original target commit ID, the new revert commit ID, `HEAD`, `git show`, `git diff`, and `git status --short` before and after each operation. Success means you can predict that revert adds history rather than moving the branch tip, can identify the commit whose patch is being reversed, and can explain what happens when the inverse patch conflicts. Never substitute `reset --hard` for a history-preserving revert when the original commit must remain in the branch history.

Beginner ~6 min read

Challenge 1

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

bash Your answer
git  HEAD

Press Ctrl⌘Enter to check your answer

Challenge 2

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

bash Your answer
git  HEAD~2

Press Ctrl⌘Enter to check your answer

Challenge 3

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

bash Your answer
git 

Press Ctrl⌘Enter to check your answer

Challenge 4

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

bash Your answer
git  <commit>

Press Ctrl⌘Enter to check your answer