Git Quiz
Thirty questions covering the whole course. Choose an answer for each, then press Check answers at the bottom to see your score and an explanation for every question.
1. What is the relationship between Git and GitHub?
Git works entirely offline; GitHub, GitLab and others add hosting and collaboration (lesson 01).
2. Which command sets your name for every repository on your computer?
--global writes to ~/.gitconfig; without it, the setting is for the current repository only (lesson 03).
3. What does git init create?
The files in the folder are untouched; .git holds everything Git knows (lesson 05).
4. What is the staging area?
You move changes there with git add (lesson 06).
5. In git status -s, what does MM before a file mean?
Left column: staging area; right column: working tree (lesson 07).
6. Which command stages modified and deleted tracked files, but not new files?
-u means "update" — only files Git already tracks (lesson 08).
7. Which commit summary follows the usual conventions best?
Imperative mood, specific, and about one change (lesson 10).
8. What does git diff --staged show?
Plain git diff shows unstaged changes (lesson 12).
9. What does HEAD~2 refer to?
~ walks back along history; ^2 would pick a second parent (lesson 13).
10. A file was committed before you added it to .gitignore. How do you stop tracking it but keep it on disk?
.gitignore only affects untracked files (lesson 14).
11. Which command discards uncommitted edits to pancakes.txt?
The discarded edits can't be recovered, because Git never stored them (lesson 16).
12. When is it safe to use git commit --amend?
Amending replaces the commit with a new one, which rewrites history (lesson 17).
13. What does git reset --soft HEAD~1 do?
--mixed would leave the changes unstaged; --hard would discard them (lesson 18).
14. You need to undo a commit that is already on the shared main branch. What should you use?
Revert adds a new commit and doesn't rewrite shared history (lesson 19).
15. You ran git reset --hard HEAD~3 by mistake. What helps you get the commits back?
The reflog records where HEAD has been, so you can reset back to it (lesson 20).
16. What is a branch in Git?
That's why creating a branch is instant (lesson 22).
17. What happens in a fast-forward merge?
--no-ff forces a merge commit instead (lesson 24).
18. Which lines does Git add to a file with a merge conflict?
Edit the file to the final version, remove the markers, then git add it (lesson 25).
19. What is the "golden rule" of rebasing?
Rebasing replaces commits, which breaks other people's copies of them (lesson 26).
20. In an interactive rebase, which command combines a commit with the previous one and discards its message?
squash also combines, but lets you edit the combined message (lesson 27).
21. When is git cherry-pick the right tool?
Picking commits you'll later merge anyway creates duplicates (lesson 28).
22. What does git stash -u include that plain git stash doesn't?
-a would also include ignored files (lesson 29).
23. What does git push -u origin feature do besides pushing?
(lesson 32)
24. What is the difference between git fetch and git pull?
Fetching is always safe; pull integrates the changes (lesson 34).
25. What is origin/main?
It's a remote-tracking branch (lesson 35).
26. Why prefer git push --force-with-lease over git push --force?
Plain --force can silently delete teammates' commits (lesson 32).
27. After a pull request is squash-merged, why does git branch -d feature say the branch is not fully merged?
Confirm the PR is merged, then delete with -D (lesson 36).
28. Which kind of tag should you use for a release?
Annotated tags record the tagger, date and a message, and can be signed (lesson 39).
29. What does git bisect do?
With git bisect run it can even test each step automatically (lesson 41).
30. You accidentally pushed a commit containing a live API key. What's the first thing to do?
The key is in history and may already be copied; only rotating it makes it useless (lessons 14 and 51).