Skip to content
Foxipa
Code Completion 4 Challenges

Complete the Git commands: Git Reset: Moving HEAD and Controlling Local State

Create a disposable repository with at least two commits. First make a new edit and stage it, then use the path form of `git reset` to unstage it without losing the working-tree edit. Next create a second commit, record its object ID, and experiment in separate disposable copies with `--soft`, `--mixed`, and `--hard` resets to its parent. For each mode, record the resulting `HEAD`, index, working-tree content, `ORIG_HEAD`, and `git status --short`. Explain exactly which states changed and which did not. Success means you can predict the state transition before running each command and then verify the prediction with `git rev-parse`, `git diff`, `git diff --cached`, file contents, and `git status --short`. Never use `--hard` on work you need to keep.

Beginner ~6 min read

Challenge 1

Complete the Git command to move refs or reset local state.

bash Your answer
git 

Press Ctrl⌘Enter to check your answer

Challenge 2

Complete the Git command to move refs or reset local state.

bash Your answer
git  HEAD -- file.txt

Press Ctrl⌘Enter to check your answer

Challenge 3

Complete the Git command to move refs or reset local state.

bash Your answer
git  --soft HEAD~1

Press Ctrl⌘Enter to check your answer

Challenge 4

Complete the Git command to move refs or reset local state.

bash Your answer
git  --mixed HEAD~1

Press Ctrl⌘Enter to check your answer