Git & GitHub Interview Question #122

What is git blame?

Advanced GitHub Actions, Repository Internals, Submodules, LFS & Diagnostic Tools Senior Advanced

Quick Interview Answer

git blame shows which commit and author last changed each line of a file. It is useful for finding the historical context of a line so you can inspect the relevant commit or discussion.

Detailed Explanation

git blame shows which commit and author last changed each line of a file. It is useful for finding the historical context of a line so you can inspect the relevant commit or discussion.

It should be treated as an investigation tool rather than a tool for assigning personal blame. Refactoring and moved code can also make simple line attribution incomplete.

Code Example

git blame Controllers/HomeController.cs

# Inspect the relevant commit afterward:
git show <commit-id>