How to Show Git Blame Inline in VS Code
Visual Studio Code displays inline Git blame information primarily through powerful extensions like GitLens, as well as through its evolving native Git integration. This article guides you through how these inline annotations work, how to enable them using extensions, and how to configure your settings for a seamless development workflow.
GitLens: The Standard for Inline Git Blame
By default, VS Code does not show inline Git blame annotations out of the box. The most common and robust way to achieve this is by installing the GitLens extension.
Once GitLens is installed, it automatically displays Git blame information inline. As you click on any line of code, a faint, grayed-out text annotation appears at the end of that line. This annotation typically shows: * The author of the last commit to touch that line. * How long ago the change was made (e.g., “3 weeks ago”). * The commit subject line.
If you hover your mouse over this inline text, GitLens displays a detailed tooltip containing the full commit hash, the commit message, the date, and options to view the commit on remote repositories like GitHub.
Native VS Code Git Blame Features
While VS Code requires extensions for full inline annotations at the end of a line, it does offer built-in features to view Git history natively: * The Timeline View: Located at the bottom of the File Explorer panel, the native Timeline view displays a chronological list of Git commits for the active file. Clicking a commit shows a diff of the changes. * Editor Gutter Indicators: VS Code natively displays colored bars in the editor gutter (next to the line numbers) to indicate added, modified, or deleted lines. Clicking these indicators shows a quick diff of the changes.
How to Configure and Customize Inline Blame
If you are using GitLens, you can customize how and when the inline blame information is displayed to prevent it from cluttering your workspace.
To edit these settings: 1. Open VS Code Settings
(Ctrl + , on Windows/Linux or Cmd + , on
macOS). 2. Search for “GitLens Current Line”. 3. Customize the following
options: * GitLens > Current Line: Enabled: Toggle
the inline annotation on or off. * GitLens > Current Line:
Format: Change what information is displayed in the annotation
(such as author name, date, or commit message).
Alternatively, you can configure this directly in your
settings.json file by adding the following
configuration:
"gitlens.currentLine.enabled": true,
"gitlens.currentLine.format": "${author, }${time, }• ${message}"