Git Blame (original) (raw)

Last Updated : 6 May, 2026

Git blame is a Git command that annotates each line in a file with the following information.

Syntax

git blame [options]

Step-by-Step Guide to use git-blame

To identify the author and commit details for a specific line in a file within a Git repository, use the appropriate Git command as shown below.

**Step 1: Move to an empty folder and initialise it with an empty git repository.

**Step 2: Clone the required repository from GitHub and navigate to the cloned directory.

cloning create-react-app repository from GitHub

**Step 3: Run the git blame command with the relative file path to view the author and commit details for each line.

git blame

**Step 4: To view details for CONTRIBUTING.md in the current directory, run the following command:

git blame CONTRIBUTING.md

**Output:

The output of the git blame command on the CONTRIBUTING.md file

**Tip: Observe that the last column of output displays the line number along with the code on that line.

**Output study

Let's examine the first line of output:

**Commit Id **Author Name **Timestamp **Code
46cf3fc43 Dan Abramov 2016-09-02 14:29:08 +0100 # Contributing to Create React App

git blame -t CONTRIBUTING.md

**Output:

raw timestamp using -t option with the git blame command

Viewing the commit details

To view detailed information about a specific commit, use the commit ID obtained from the git blame output.

Steps:

  1. Copy the commit ID from the git blame result.
    (Example: 46cf3fc43 from CONTRIBUTING.md)
  2. Run the following command:

git log -p

**Example:

git log -p 46cf3fc43

Options with git blame

Git provides multiple options to analyze file modifications in detail.

**To view output for a range of lines

git blame -L start-line,end-line

The below command shows output for lines 2 to 5 both inclusive.

git blame -L 2,5 CONTRIBUTING.md

The output is shown below:

The output of the git blame command for a given range of lines

**Note: You will get the same output for command - _git blame -L 4,+3 README.md. Here 4,+3 signifies output for 3 lines starting from the fourth line.

**To view the author email id

git blame -e CONTRIBUTING.md

The above command will show the author's email id instead of the author's name in the result. The output is shown below:

**To view changes not older than the given time

git blame --since=3.months CONTRIBUTING.md

**Output:

The output of the git blame command with commits not older than three months (without removing unrequired commits)

git blame --since=3.months CONTRIBUTING.md | grep -v '^^'

The output of the git blame command with commits not older than three months (after removing unrequired commits)

**An alternate option to the command line (GUI based)

Git hosting sites like GitHub, Bitbucket, GitLab offer GUI displays for git blame, which gives a clear display of modification history in a file.

**Example: GitHub

**Step 1: Navigate to the file for which you want to see the modification history and click on the Blame option as shown below.

**Step 2: The structure of output is described in the image below :

labeled picture of blame option on GitHub

git blame is a powerful command for analyzing line-level commit history and works effectively with other Git commands for deeper repository inspection.