Git Level 2 Test
A new driver who can steer around an empty car park still has to show they can drive in traffic, with other cars around them. This test does the same for Git: it checks whether you can work alongside other people. It covers branches and HEAD, merging and conflicts, remotes, pushing and pulling, pull requests and forks, stashing and tags. If you pass it, you are ready to rebase and rewrite history.
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 lessons from "Git Branch" to "Releases and Semantic Versioning".
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: A Merge Commit
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/books
echo 'Books fee: $600' > books.txt
git add books.txt
git commit --quiet -m "Add the books fee"
git switch --quiet main
echo 'Exam fee: $800' > exam.txt
git add exam.txt
git commit --quiet -m "Add the exam fee"
git merge --quiet --no-edit feature/books
git log --graph --format=%sShow 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/books
echo 'Books fee: $600' > books.txt
git add books.txt
git commit --quiet -m "Add the books fee"
git switch --quiet main
echo 'Exam fee: $800' > exam.txt
git add exam.txt
git commit --quiet -m "Add the exam fee"
git merge --quiet --no-edit feature/books
git log --graph --format=%s* Merge branch 'feature/books'
|\
| * Add the books fee
* | Add the exam fee
|/
* Add the term feeWhy this output?
Both branches had a new commit, so a fast-forward was impossible and Git made a merge commit with the default message "Merge branch 'feature/books'". The graph shows main's own commit on the left line and the branch's commit on the right, joining at the merge. Revise: Fast-Forward vs Merge Commit.
Puzzle 2: Two Stashes
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"
echo "Late fee idea" >> fees.txt
git stash push --quiet -m "late fee idea"
echo "Exam fee idea" >> fees.txt
git stash push --quiet -m "exam fee idea"
git stash listShow 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"
echo "Late fee idea" >> fees.txt
git stash push --quiet -m "late fee idea"
echo "Exam fee idea" >> fees.txt
git stash push --quiet -m "exam fee idea"
git stash liststash@{0}: On main: exam fee idea
stash@{1}: On main: late fee ideaWhy this output?
Stashes are a stack: the newest is always stash@{0}, and older ones move down one number. Each entry says which branch it was made on and its message. Revise: Git Stash.
Puzzle 3: Behind After a Fetch
cd "$(mktemp -d)"
git init --quiet --bare server.git
git clone --quiet server.git navika 2>/dev/null
cd navika
echo 'Term fee: $12,000' > fees.txt
git add fees.txt
git commit --quiet -m "Add the term fee"
git push --quiet -u origin main
cd ..
git clone --quiet server.git advitha
cd advitha
echo 'Late fee: $250' >> fees.txt
git commit --quiet -am "Add the late fee"
git push --quiet
cd ../navika
git fetch --quiet
git status --short --branchShow solution
cd "$(mktemp -d)"
git init --quiet --bare server.git
git clone --quiet server.git navika 2>/dev/null
cd navika
echo 'Term fee: $12,000' > fees.txt
git add fees.txt
git commit --quiet -m "Add the term fee"
git push --quiet -u origin main
cd ..
git clone --quiet server.git advitha
cd advitha
echo 'Late fee: $250' >> fees.txt
git commit --quiet -am "Add the late fee"
git push --quiet
cd ../navika
git fetch --quiet
git status --short --branch## main...origin/main [behind 1]Why this output?
git fetch updated origin/main with Advitha's commit but didn't touch Navika's main. So her branch is one commit behind its upstream, and git status --short --branch shows it in brackets. git pull (or git merge origin/main) would fast-forward it. Revise: Git Fetch.
What Your Score Means
| Score (out of 23) | What it means | What to do next |
|---|---|---|
| 20 to 23 | You collaborate with confidence | Move on to Git Rebase |
| 16 to 19 | A pass, with a few gaps | Read the lessons linked from the questions you missed, then move on |
| Under 16 | Not yet | Reread the lessons behind your wrong answers, do Lab 2 on Git Labs, and take the test again |
Was this tutorial helpful?