Git file blame

  • Tier: Free, Premium, Ultimate
  • Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated

Git blame provides more information about every line in a file, including the last modified time, author, and commit hash.

View blame for a file

History

Prerequisites:

  • The file type must be text-based. The GitLab UI does not display git blame results for binary files.

To view the blame for a file:

  1. On the left sidebar, select Search or go to and find your project.
  2. Select Code > Repository.
  3. Select the file you want to review.
  4. Either:
    • To change the view of the current file, in the file header, select Blame.
    • To open the full blame page, in the upper-right corner, select Blame.
  5. Go to the line you want to see.

When you select Blame, this information is displayed:

Git blame output

To see the precise date and time of the commit, hover over the date. The vertical bar to the left of the user avatar shows the general age of the commit. The newest commits have a dark blue bar. As the age of the commit increases, the bar color changes to light gray.

Blame previous commit

To see earlier revisions of a specific line:

  1. On the left sidebar, select Search or go to and find your project.
  2. Select Code > Repository.
  3. Select the file you want to review.
  4. In the upper-right corner, select Blame, and go to the line you want to see.
  5. Select View blame prior to this change ( doc-versions ) until you’ve found the changes you’re interested in viewing.

Ignore specific revisions

History

The availability of this feature is controlled by a feature flag. For more information, see the history.

To configure Git blame to ignore specific revisions:

  1. In the root of your repository, create a .git-blame-ignore-revs file.

  2. Add the commit hashes you want to ignore, one per line. For example:

    a24cb33c0e1390b0719e9d9a4a4fc0e4a3a069cc
    676c1c7e8b9e2c9c93e4d5266c6f3a50ad602a4c
  3. Open a file in the blame view.

  4. Select the Blame preferences dropdown list.

  5. Select Ignore specific revisions.

The blame view refreshes and skips the revisions specified in the .git-blame-ignore-revs file, showing the previous meaningful changes instead.