0
0
Gitdevops~20 mins

git blame for line-by-line history - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Git Blame Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:00remaining
Identify the commit hash from git blame output
You run git blame -L 10,10 README.md and see this output:
e3a1b2c4 (Alice 2024-05-01 10:15:30 +0000 10) Fix typo in introduction

What is the commit hash for the change on line 10?
AAlice
Be3a1b2c4
C2024-05-01
D10
Attempts:
2 left
💡 Hint
The commit hash is the first part before the author name.
🧠 Conceptual
intermediate
0:45remaining
Purpose of git blame
What is the main purpose of the git blame command?
ATo show who last modified each line of a file
BTo undo the last commit
CTo merge two branches
DTo list all branches
Attempts:
2 left
💡 Hint
Think about tracking changes line by line.
Troubleshoot
advanced
1:30remaining
Why does git blame show wrong author for a line?
You notice git blame shows an unexpected author for a line you recently changed. What could cause this?
AYou forgot to stage the file before committing
BYou ran <code>git blame</code> on a different branch
CThe line was copied from another file without changes
DYour local git config has wrong user.email
Attempts:
2 left
💡 Hint
Think about how git tracks line history when lines are copied.
🔀 Workflow
advanced
2:00remaining
Using git blame to find when a bug was introduced
You want to find when a bug was introduced in a file. Which git command sequence helps you use git blame effectively?
ARun <code>git blame</code> on the buggy line, then use <code>git show</code> on the commit hash
BRun <code>git log</code> to list commits, then <code>git merge</code> to combine fixes
CRun <code>git diff</code> between branches, then <code>git blame</code> on the whole file
DRun <code>git reset</code> to undo changes, then <code>git blame</code> to check authors
Attempts:
2 left
💡 Hint
First find the commit that last changed the line, then inspect that commit.
Best Practice
expert
2:30remaining
Optimizing git blame output for large files
For a large file, running git blame is slow. Which option improves performance without losing line history?
AUse <code>git blame --show-name</code> to display file names
BUse <code>git blame --incremental</code> to get detailed output efficiently
CUse <code>git blame --reverse</code> to blame lines backwards
DUse <code>git blame --ignore-rev</code> with a commit hash to skip known refactors
Attempts:
2 left
💡 Hint
Skipping commits that only refactor code can speed up blame.