Git Refresh Test
Someone who learned to drive twenty years ago drives perfectly well, yet a new car surprises them: it keeps itself in its lane, the handbrake is a button, and the dashboard asks for an update. This test is for developers in that position with Git. You use it every day, perhaps with the same five commands you learned years ago. It checks the newer commands and settings that make Git safer, and the topics that interviews ask about most.
How the Test Works
- What's in it: 20 multiple-choice questions, then 3 puzzles where you work out what Git prints at the end of a short terminal session.
- Time: 30 minutes, without notes and without running Git.
- Pass mark: 16 out of 23. The quiz marks the 20 questions for you; give yourself one point for each puzzle you get exactly right.
- What it covers: the three areas, undoing, modern commands, pulling and force pushing, rebase, recovery and debugging.
Part 1: 20 Questions
Part 2: "What Does Git Print?" Puzzles
Work out what the last command of each session prints, on paper, before you open the solution. Each session starts in a new, empty temporary folder, with your name and email address set and main as the default branch.
Puzzle 1: Conflict Markers with the Base
cd "$(mktemp -d)"
git init --quiet
git config merge.conflictStyle zdiff3
echo 'Late fee: $250' > fees.txt
git add fees.txt
git commit --quiet -m "Add the late fee"
git switch --quiet -c advitha
echo 'Late fee: $275' > fees.txt
git commit --quiet -am "Set the late fee to 275"
git switch --quiet main
echo 'Late fee: $300' > fees.txt
git commit --quiet -am "Set the late fee to 300"
git merge --quiet advitha > /dev/null
cat fees.txtShow solution
cd "$(mktemp -d)"
git init --quiet
git config merge.conflictStyle zdiff3
echo 'Late fee: $250' > fees.txt
git add fees.txt
git commit --quiet -m "Add the late fee"
git switch --quiet -c advitha
echo 'Late fee: $275' > fees.txt
git commit --quiet -am "Set the late fee to 275"
git switch --quiet main
echo 'Late fee: $300' > fees.txt
git commit --quiet -am "Set the late fee to 300"
git merge --quiet advitha > /dev/null
cat fees.txt<<<<<<< HEAD
Late fee: $300
||||||| ca6af41
Late fee: $250
=======
Late fee: $275
>>>>>>> advithaWhy this output?
With zdiff3, the conflict shows three versions: ours (300) after <<<<<<< HEAD, the common ancestor (250) after ||||||| and the base commit's short ID (yours will differ, so it doesn't count when marking), and theirs (275) after =======. Seeing that the base was 250 shows that both sides raised the fee, which helps decide the right value. Revise: Useful Git Settings.
Puzzle 2: Stacked Branches Move Together
cd "$(mktemp -d)"
git init --quiet
echo 'Term fee: $12,000' > fees.txt
git add fees.txt
git commit --quiet -m "Add the term fee"
git switch --quiet -c feature/api
echo "API" > api.txt
git add api.txt
git commit --quiet -m "Add the fee API"
git switch --quiet -c feature/ui
echo "UI" > ui.txt
git add ui.txt
git commit --quiet -m "Add the fee page"
git switch --quiet main
echo 'Exam fee: $800' >> fees.txt
git commit --quiet -am "Add the exam fee"
git switch --quiet feature/ui
git rebase --quiet --update-refs main
git log --format="%s%d"Show solution
cd "$(mktemp -d)"
git init --quiet
echo 'Term fee: $12,000' > fees.txt
git add fees.txt
git commit --quiet -m "Add the term fee"
git switch --quiet -c feature/api
echo "API" > api.txt
git add api.txt
git commit --quiet -m "Add the fee API"
git switch --quiet -c feature/ui
echo "UI" > ui.txt
git add ui.txt
git commit --quiet -m "Add the fee page"
git switch --quiet main
echo 'Exam fee: $800' >> fees.txt
git commit --quiet -am "Add the exam fee"
git switch --quiet feature/ui
git rebase --quiet --update-refs main
git log --format="%s%d"Add the fee page (HEAD -> feature/ui)
Add the fee API (feature/api)
Add the exam fee (main)
Add the term feeWhy this output?
Rebasing feature/ui replayed both of its commits onto main. Because of --update-refs, feature/api, which pointed at the first of those commits, moved to the rebased copy, so it still sits right under feature/ui. Without the option, feature/api would have stayed on the old commit. Revise: Rebase Onto and Stacked Branches.
Puzzle 3: Restore from an Older Commit
cd "$(mktemp -d)"
git init --quiet
echo 'Late fee: $250' > fees.txt
git add fees.txt
git commit --quiet -m "Add the late fee"
echo 'Late fee: $300' > fees.txt
git commit --quiet -am "Raise the late fee"
git restore --source=HEAD~1 fees.txt
cat fees.txt
git status --shortShow solution
cd "$(mktemp -d)"
git init --quiet
echo 'Late fee: $250' > fees.txt
git add fees.txt
git commit --quiet -m "Add the late fee"
echo 'Late fee: $300' > fees.txt
git commit --quiet -am "Raise the late fee"
git restore --source=HEAD~1 fees.txt
cat fees.txt
git status --shortLate fee: $250
M fees.txtWhy this output?
git restore --source=HEAD~1 wrote the older version into the working folder only. The branch didn't move, so git status shows the file as modified but not staged ( M). Add --staged --worktree to restore both the staging area and the file. (This puzzle's last two commands both print.) Revise: Git Restore.
What Your Score Means
| Score (out of 23) | What it means | What to do next |
|---|---|---|
| 20 to 23 | Your Git is up to date | Try the Git Deep Dive Test, or the Git Mock Interview |
| 16 to 19 | Mostly up to date | Read the lessons linked from the questions you missed |
| Under 16 | Time for a refresh | Revise the lessons on the topics you missed, starting with Working Tree, Staging Area and Repository, then take the test again |
Was this tutorial helpful?