Git Advanced Quiz
Rebase, reset, reflog and recovery — the commands that reshape history, and how to undo them when they go wrong.
Start the quizSample questions from this quiz
A preview of the style and depth. Try each one, then reveal the answer — or skip straight to the timed quiz.
1. You have 3 uncommitted modified files. What happens?
git reset --hard HEAD~1- Git refuses because the tree is dirty
- The last commit is undone but the changes stay in the working tree
- The last commit is undone and staged
- The last commit is discarded AND all uncommitted changes are lost
Show answer
Answer: The last commit is discarded AND all uncommitted changes are lost. `--hard` resets the branch pointer, the index and the working tree, so uncommitted work is destroyed with no reflog entry to recover it. `--soft` keeps everything staged and `--mixed` (the default) keeps it unstaged — both are recoverable.
2. You accidentally ran `git reset --hard` and lost a commit. What recovers it?
git reflog
# then...- git revert HEAD
- git reset --hard <sha> using the sha shown in the reflog
- git pull --force
- Nothing — the commit is unrecoverable
Show answer
Answer: git reset --hard <sha> using the sha shown in the reflog. The reflog records every position HEAD has held, so a 'lost' commit is usually still reachable for around 90 days before garbage collection. This is the single most valuable recovery tool in Git — the commit was orphaned, not deleted.
3. What is the practical difference between `git revert HEAD` and `git reset --hard HEAD~1`?
- revert only works on merge commits
- They are equivalent
- revert adds a new commit undoing the change; reset removes the commit from history
- reset is safe on shared branches, revert is not
Show answer
Answer: revert adds a new commit undoing the change; reset removes the commit from history. `revert` is additive and therefore safe on a shared branch — history is preserved and everyone's clone stays consistent. `reset` rewrites history, so on a pushed branch it forces others to reconcile. The rule of thumb: revert public, reset local.
Frequently asked questions
How many questions are in this Git quiz?+
30 questions, with a 45-minute time limit. Every question includes a written explanation of the correct answer.
Is this Git quiz free?+
Yes. Every quiz on CodexQuizz is free and needs no account. You only enter a name if you choose to post your score to the leaderboard.
What level is the advanced quiz aimed at?+
Rebase, reset, reflog and recovery — the commands that reshape history, and how to undo them when they go wrong.
Can I use this to prepare for a Git interview?+
Yes. The questions cover the topics that come up in Git technical screens, and the explanations are written so that a wrong answer still teaches you the underlying concept.
Ready to test your Git?
30 questions, 45 minutes. Free, no sign-up.
Start now