Chapter 54: Git Quiz
Git Quiz Time
This is not a scary exam. This is your personal victory lap — a chance to see how much muscle memory you’ve built and where you still need 2–3 more practice rounds.
I’m going to play the role of your friendly-but-firm Hyderabad Git teacher who really wants you to succeed. We’ll do 20 practical, realistic questions that cover the entire spectrum we learned today.
Rules (very important):
- Try to answer without scrolling back to previous messages first (force recall)
- Write your answer in your head or on paper
- After each question I’ll give the correct answer + explanation + why it matters in real life
- If you get < 12/20 correct → totally normal — just means you need to re-do 5–10 exercises from earlier
- If you get 16+ → you are already stronger than most developers with 1–2 years of Git experience
Ready? Let’s begin.
Git Quiz – 20 Questions (2026 real-world level)
Q1 You just ran git commit -m “fix typo” but forgot to stage style.css. What is the fastest, safest way to include it in the same commit?
Q2 What is the difference between git reset –soft HEAD~1 and git reset –hard HEAD~1? (Explain both the effect on history and on your working directory)
Q3 You ran git reset –hard HEAD~3 and now panic because three days of work seem gone. What single command do you type first to see if you can recover?
Q4 You want a clean linear history before creating a Pull Request. You are on branch feature/add-search and main has new commits. What command do you run? (bonus: what do you do after if you already pushed the branch before?)
Q5 What is the safest command to undo a commit that was already pushed to the main branch and other people pulled it?
Q6 You see these lines in a file during a merge:
|
0 1 2 3 4 5 6 7 8 9 10 |
<<<<<<< HEAD color: blue; ======= color: green; >>>>>>> feature/new-theme |
Explain in plain English what each marker means and how you decide what to keep.
Q7 What command do you use to copy only one specific commit from branch bugfix/payment to your current branch release/v2?
Q8 What is the difference between these two lines in .gitignore?
|
0 1 2 3 4 5 6 7 |
node_modules/ !node_modules/.prisma/client |
Q9 You want Git to always use LF line endings for all shell scripts and Python files, even on Windows. What do you write in .gitattributes?
Q10 You want Git to treat .png and .jpg files as binary (no line-ending conversion, no diff). What line do you add to .gitattributes?
Q11 What does git submodule update –init –recursive do? (Explain in one sentence what happens if you forget to run it after cloning a repo that has submodules)
Q12 You want every commit you make to be automatically GPG-signed so GitHub shows the green “Verified” badge. What three git config commands do you run globally?
Q13 What is the main difference between git merge and git rebase when you want to bring main changes into your feature branch?
Q14 You want to run ESLint + Prettier automatically before every commit. What Git hook do you use, and where do you put the script in a modern project?
Q15 What is the safest way to push after you rebased a branch that you had already pushed before?
Q16 What single command shows you a beautiful graph of all branches and their commit relationships (including remote branches)?
Q17 You want GitHub Actions to run your Jest tests automatically on every push and every pull request to main. What is the minimal file name and folder where you put the workflow YAML?
Q18 Your repository has grown to 3 GB because of old video files you no longer need in history. What modern tool (not filter-branch) do you use to remove them from all history, and what flag do you use to track large files going forward?
Q19 What command do you run every morning to make sure your local main is up-to-date and remove any deleted remote branches from your tracking list?
Q20 You are in the middle of a conflicted merge. You fixed the files but now want to give up and go back to before the merge started. What command do you type?
Now pause and try to answer them mentally or on paper
Once you’re ready, scroll down for the answers + explanations + real-life why-it-matters notes.
(If you want, reply with your answers to any 5 questions — I’ll score you and explain mistakes gently.)
Answers & Explanations
Q1 git add style.css && git commit –amend –no-edit (or git commit –amend if you want to improve the message too)
Why it matters: Fixing “just one more file” or bad message is the #1 most common amend use case.
Q2 –soft: keeps changes staged (ready to re-commit) –hard: throws away both staging and working directory changes –mixed (default): keeps changes in working directory but unstages them
Why it matters: –hard is the one that causes most panic calls to teammates at 2 a.m.
Q3 git reflog
Why it matters: reflog is your personal time machine — almost every “I lost everything” story ends with reflog saving the day.
Q4 git fetch origin && git rebase origin/main (after already pushed → git push –force-with-lease)
Why it matters: Clean linear history before PR = reviewers love you.
Q5 git revert <bad-commit-hash>
Why it matters: Keeps history honest and safe on shared branches.
Q6 <<<<<<< HEAD = what is in your current branch ======= = separator >>>>>>> branch-name = what is coming from the other branch
Why it matters: Markers are Git’s polite way of saying “I can’t decide — you choose”.
Q7 git cherry-pick <commit-hash>
Why it matters: Surgical precision — take only the good part.
Q8 node_modules/ = ignore entire folder !node_modules/.prisma/client = exception — do track this subfolder/file
Why it matters: Lets you ignore 99% of heavy folder but keep generated Prisma client.
Q9 *.sh text eol=lf *.py text eol=lf
Why it matters: Prevents Windows CRLF corruption of scripts.
Q10 *.png binary *.jpg binary
Why it matters: Stops Git from trying to diff binaries (which corrupts them).
Q11 Initializes and checks out the correct commit for every submodule. If you forget it → submodules are empty folders → teammates scream.
Q12
|
0 1 2 3 4 5 6 7 8 9 |
git config --global user.signingkey <your-key-id> git config --global commit.gpgsign true # optional git config --global tag.gpgsign true |
Q13 Merge = creates merge commit (shows parallel work) Rebase = rewrites your commits on top (linear history)
Q14 pre-commit hook (usually managed by Husky / lefthook in .husky/pre-commit)
Q15 git push –force-with-lease
Q16 git lg (if you set the alias) or git log –graph –oneline –decorate –all
Q17 .github/workflows/ci.yml (or any name.yml inside workflows/)
Q18 git filter-repo –strip-blobs-bigger-than 10M or migrate to LFS with git lfs migrate import –include=”*.mp4,*.mov”
Q19 git fetch –prune origin
Q20 git merge –abort
How many did you get right? Even 10/20 is excellent — means the concepts are sinking in.
Want me to make a harder 20-question “final exam” version? Or help you fix any specific question you missed?
You’ve earned a standing ovation — you now know Git at a level most developers never reach.
Very, very proud of you! 🎓🚀
Any last question or celebration wish before we close the class? 😄
