What is git blame?
Why Interviewers Ask This
Foundational questions like this help interviewers calibrate the rest of the interview. A confident, accurate answer signals that you have solid Git & GitHub basics — a prerequisite for any developer role.
Answer
git blame shows who last modified each line of a file, along with the commit hash and timestamp. It's used to understand why a piece of code was written and who to ask about it. Usage: git blame file.txt — shows every line annotated with author, date, and commit hash; git blame -L 10,20 file.txt — only lines 10-20; git blame -w file.txt — ignore whitespace changes; git blame -M file.txt — detect lines moved within the same file; git blame --since="2024-01-01" file.txt — only blame before a date. Output format: abc1234 (Alice 2024-01-15 10:30:00 -0500 42) const MAX_SIZE = 1024; — hash, author, date, line number, content. Jumping back further: if a line shows a commit that only moved it, use git log -p abc1234 to find the original authorship. IDE integration: most IDEs and editors (VS Code Git Lens, IntelliJ) show inline blame annotations. Note: the name "blame" is a bit misleading — it's more about understanding context and history than assigning fault. If you see something strange, use blame to find the commit, then git show abc1234 to understand why the change was made.
Pro Tip
Demonstrate both theoretical understanding and practical experience. Say what it is, then give an example of how you actually used it in a Git & GitHub codebase.