CodeBlanks Logo Icon CodeBlanks

git blame

Learn line authors with git blame.

Introduction to git blame

git blame shows which commit last modified each line in a file. Its output includes the commit ID, author, date, and line content. This helps you investigate who originally added or changed a particular line of code.

git blame app.js

This command lists attribution information for every line in the file. Blame is not about assigning fault; it is a tool for understanding code history.

Reading blame output

In blame output, each line begins with the short ID of the relevant commit. Author and date information follow, and the source code line appears at the end. After identifying the commit that last changed a line, you can inspect that commit with git show.

git blame app.js
git show a12bc34

This approach helps you understand which change introduced the line's latest modification.

Practice Get blame output for a file

Write the Git command to inspect the author and commit information for every line in routes.php.

Starter code

terminal
# routes.php satırlarının geçmişini incele

Expected output

Blame information displayed for routes.php.

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Which command shows the commit and author information for the last modification of every line in a file?

  • git blame app.js Correct answer
  • git diff app.js
  • git status app.js
  • git log app.js

Explanation: git blame displays file lines together with their commit and author information.

2 Inspect line attribution in a file

Question
git ____ app.js
Answer
git blame app.js

Explanation: Use git blame to view line history and author information for a file.

3 Information in blame output

Term Meaning
Commit kimliği Marks the commit that changed the line
Yazar Shows who made the change
Tarih Indicates the commit date
Satır içeriği Shows the source code text

All lessons in Advanced