Git Log Mastery — History, Diff, Blame — Concept Check
Questions on Git Log Mastery — History, Diff, Blame. git log, git diff, and git blame are your detective tools. Knowing how to filter, format, and search commit history is essential for debugging production issues, reviewing code, and understanding a codebase.
Questions in this quiz
8 questions on Git Log Mastery — History, Diff, Blame — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.You need to find out which recent changes might have introduced a bug in the 'src/auth.js' file. Which command will help you identify the commits that touched this file?
- Agit diff --name-only HEAD~5 HEAD
- Bgit log -- src/auth.js
- Cgit blame src/auth.js
- Dgit bisect start
2.A developer wants to know who last modified lines 10 to 25 in 'src/auth.js'. Which command should they use?
- Agit bisect start
- Bgit log -L 10,25:src/auth.js
- Cgit blame -L 10,25 src/auth.js
- Dgit diff HEAD~1 -- src/auth.js
3.You are investigating a bug and want to see the net changes over the last three commits. Which command should you use?
- Agit blame src/auth.js
- Bgit log --oneline
- Cgit diff --staged
- Dgit diff HEAD~3 HEAD
4.You're tasked with finding commits by either 'Akshay' or 'John'. Which command will achieve this?
- Agit log --author="akshay|john"
- Bgit log --author="Akshay, John"
- Cgit log --author="Akshay John"
- Dgit log --author="Akshay" --author="John"
5.A teammate suggests using 'git blame' to find the commit that introduced a bug. Why is this incorrect?
- Agit blame is used to filter commit history
- Bgit blame finds the first bad commit
- Cgit blame is used to compare branches
- Dgit blame shows who last modified each line, not the commit introducing a bug
6.You want to format git log output to show the short hash, author name, and subject. Which command should you use?
- Agit log --pretty=format:"%h | %an | %s"
- Bgit log --format="%H %an %s"
- Cgit log --oneline
- Dgit log --pretty=short
7.A developer wants to compare the differences between the main branch and a feature branch, ignoring whitespace changes. Which command should they use?
- Agit diff --stat main feature/cart
- Bgit diff --staged main feature/cart
- Cgit diff --name-only main feature/cart
- Dgit diff -w main feature/cart
8.You need to find commits that added or removed a specific string 'validateEmail'. Which command will help you?
- Agit log --grep="validateEmail"
- Bgit log -G "validateEmail"
- Cgit log -S "validateEmail"
- Dgit diff -S "validateEmail"