Git Level 5 Test

Updated · 9 min read
mediumGit 2.53gittestquizprofessionalassessment

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

Level 5 test: 20 questions

20 questions
1Which Git does VS Code's Source Control view use?
2Where are IntelliJ IDEA's shelved changes stored?
3Which graphical tool that comes with Git shows the commit graph of all branches?
4Which folder should a Maven project's .gitignore list?
5A CI job fails with ./mvnw: Permission denied. What fixes it for everyone?
6What does git describe print two commits after the annotated tag v1.2.0?
7Why does git describe often fail on a CI server?
8git push fails with "Updates were rejected because the remote contains work that you do not have locally". What do you do?
9What does "fatal: refusing to merge unrelated histories" mean?
10"error: src refspec main does not match any" usually means:
11Git says your local changes "would be overwritten by checkout". What keeps the changes?
12Why does git branch -d feature say the branch "is not fully merged"?
13"Permission denied (publickey)" appears on git push. What is the first thing to try?
14When is it safe to delete .git/index.lock?
15HTTPS pushes fail with "Authentication failed", although your account password is right. Why?
16Which modern command replaces git checkout -- fees.txt?
17Which form reads a setting with the git config subcommands added in Git 2.46?
18What does Git's BreakingChanges document say about the Git 3.0 release date?
19Which default is planned to change for new repositories in Git 3.0?
20Which command converts an existing repository's references to the reftable format?

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

Terminal
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
Terminal
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)"
Output
100755 mvnw
Why 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

Terminal
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 push
Show solution
Terminal
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 push
Output
fatal: 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

Terminal
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.java
Show solution
Terminal
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.java
Output
build.sh: eol: lf
build.cmd: eol: crlf
App.java: eol: unspecified
Why 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 meansWhat to do next
20 to 23Ready for professional Git workTake the Git Mock Interview and do Lab 5 on Git Labs
16 to 19A pass, with a few gapsRead the lessons linked from the questions you missed, then take the mock interview
Under 16Not yetReread the lessons behind your wrong answers, especially the three error-message lessons, and take the test again

Was this tutorial helpful?