Git Level 1 Test

Updated · 9 min read

A swimming instructor doesn't move a child to the deep end because they have attended ten lessons. They ask the child to swim one length on their own, and then they decide. This test is your length of the pool for the first level of the Git course: what Git is, setting it up, the three areas, recording changes, reading history and undoing mistakes. If you pass it, you are ready for branches. If you don't, each answer tells you exactly which lesson to read again.

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. Answer the puzzles on paper first; run them only to check afterwards.
  • Pass mark: 16 out of 23. The quiz marks the 20 questions for you. Mark the puzzles yourself, one point each, and add them to your quiz score.
  • What it covers: the lessons from "What Is Version Control" to "Git Clean".

Part 1: 20 Questions

Level 1 test: 20 questions

20 questions
1What makes Git a distributed version control system?
2Does Git store each commit as a list of differences or as a snapshot?
3Which command sets the name recorded in your commits, for every repository on your computer?
4Where does Git keep a repository's history?
5What are the three areas a change moves through?
6git status --short shows MM fees.txt. What does it mean?
7What does git add -p let you do?
8Which subject line follows the usual commit message rules?
9You added target/ to .gitignore, but target/App.class still shows as modified. Why?
10Which command renames a tracked file so Git records the move?
11Which command shows one line per commit for the whole project history?
12What does git diff --staged show?
13In a diff, what does a line starting with - mean?
14What does HEAD~2 refer to?
15Which command shows one commit's message and changes?
16Which command throws away unstaged changes to fees.txt?
17Which command unstages fees.txt but keeps the change in the file?
18What does git reset --hard HEAD~1 do?
19The last commit is already pushed to a shared branch and was wrong. What is the safe way to undo it?
20What should you run before git clean -fd?

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 (cd "$(mktemp -d)"), with your name and email address already set. Give yourself one point for each puzzle you get exactly right.

Puzzle 1: Edited After Staging

Terminal
cd "$(mktemp -d)"
git init --quiet
echo 'Term fee: $12,000' > fees.txt
git add fees.txt
echo 'Late fee: $250' >> fees.txt
git commit --quiet -m "Add the fees"
git status --short
Show solution
Terminal
cd "$(mktemp -d)"
git init --quiet
echo 'Term fee: $12,000' > fees.txt
git add fees.txt
echo 'Late fee: $250' >> fees.txt
git commit --quiet -m "Add the fees"
git status --short
Output
 M fees.txt
Why this output?

git add staged the file as it was then, with only the term fee. The late fee line was added afterwards and never staged, so the commit doesn't contain it, and git status shows the file as modified in the working tree ( M, with a space on the left). Revise: Git Add: Staging Changes.

Puzzle 2: An Exception to an Ignore Rule

Terminal
cd "$(mktemp -d)"
git init --quiet
printf "%s\n" "*.log" "!keep.log" > .gitignore
touch app.log keep.log notes.txt
git status --short
Show solution
Terminal
cd "$(mktemp -d)"
git init --quiet
printf "%s\n" "*.log" "!keep.log" > .gitignore
touch app.log keep.log notes.txt
git status --short
Output
?? .gitignore
?? keep.log
?? notes.txt
Why this output?

*.log ignores every log file, and !keep.log makes an exception for one. So app.log is hidden, while .gitignore, keep.log and notes.txt are listed as untracked (??), in alphabetical order. Revise: Git .gitignore.

Puzzle 3: A Soft Reset

Terminal
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: $250' >> fees.txt
git commit --quiet -am "Add the late fee"
git reset --soft HEAD~1
git status --short
Show solution
Terminal
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: $250' >> fees.txt
git commit --quiet -am "Add the late fee"
git reset --soft HEAD~1
git status --short
Output
M  fees.txt
Why this output?

--soft moved the branch back one commit but left the staging area as it was, so the late fee change is staged again (M with the letter on the left), ready to be committed differently. With --mixed it would be unstaged ( M), and with --hard it would be gone. Revise: Git Reset: Soft, Mixed and Hard.

What Your Score Means

Score (out of 23)What it meansWhat to do next
20 to 23You know the basics wellMove on to Git Branch
16 to 19A pass, with a few gapsRead the lessons linked from the questions you missed, then move on
Under 16Not yetReread the lessons behind your wrong answers, do Lab 1 and Lab 6 on Git Labs, and take the test again

Was this tutorial helpful?