Git Level 5 Test
A pilot's final check isn't about how a wing works. It is about the real cockpit: the instruments they will use, the warnings they will see, and what to do when one lights up. This last level test is the same for Git: the tools you use every day, setting up a real Java project, reading error messages and fixing them, and knowing what is new and what is coming. Pass it, take the Git Mock Interview, and you have finished the course.
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 in VS Code and IntelliJ IDEA" to "Git 3.0: What Is Planned".
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: The Wrapper's Mode
cd "$(mktemp -d)"
git init --quiet
printf '#!/bin/sh\necho "Maven wrapper"\n' > mvnw
chmod -x mvnw
git add mvnw
git update-index --chmod=+x mvnw
git ls-files --format="%(objectmode) %(path)"Show solution
cd "$(mktemp -d)"
git init --quiet
printf '#!/bin/sh\necho "Maven wrapper"\n' > mvnw
chmod -x mvnw
git add mvnw
git update-index --chmod=+x mvnw
git ls-files --format="%(objectmode) %(path)"100755 mvnwWhy this output?
The file on disk isn't executable, so git add staged it as 100644. git update-index --chmod=+x changed the mode in the index to 100755, which is what every clone will get. Revise: Git for Java Projects.
Puzzle 2: A Branch with No Upstream
cd "$(mktemp -d)"
git init --quiet --bare server.git
git clone --quiet server.git fee-tracker 2>/dev/null
cd fee-tracker
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
git switch --quiet -c feature/books
git pushShow solution
cd "$(mktemp -d)"
git init --quiet --bare server.git
git clone --quiet server.git fee-tracker 2>/dev/null
cd fee-tracker
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
git switch --quiet -c feature/books
git pushfatal: The current branch feature/books has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin feature/books
To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.Why this output?
main got an upstream with -u, but the new branch feature/books has none, so git push doesn't know where to send it, and says exactly which command to run. push.autoSetupRemote true would have set it up automatically. Revise: Common Git Errors: Push and Pull.
Puzzle 3: Line Endings by File Type
cd "$(mktemp -d)"
git init --quiet
printf "%s\n" "* text=auto" "*.sh text eol=lf" "*.cmd text eol=crlf" > .gitattributes
git check-attr eol -- build.sh build.cmd App.javaShow solution
cd "$(mktemp -d)"
git init --quiet
printf "%s\n" "* text=auto" "*.sh text eol=lf" "*.cmd text eol=crlf" > .gitattributes
git check-attr eol -- build.sh build.cmd App.javabuild.sh: eol: lf
build.cmd: eol: crlf
App.java: eol: unspecifiedWhy this output?
check-attr reads the rules for the names given, even if the files don't exist. build.sh and build.cmd match their eol rules, while App.java only matches * text=auto, which sets no eol, so it is unspecified: Git uses LF in the repository and the platform's choice in the working folder. Revise: Git .gitattributes and Line Endings.
What Your Score Means
| Score (out of 23) | What it means | What to do next |
|---|---|---|
| 20 to 23 | Ready for professional Git work | Take the Git Mock Interview and do Lab 5 on Git Labs |
| 16 to 19 | A pass, with a few gaps | Read the lessons linked from the questions you missed, then take the mock interview |
| Under 16 | Not yet | Reread the lessons behind your wrong answers, especially the three error-message lessons, and take the test again |
Was this tutorial helpful?