Git Blame
Optional inline blame.
A simple extension for git blame.

Help
Usage
- Double click status blame to switch from short form or long form.
- Optimized for small screens so only one pane is used for log display.
- See blame for any file in the editor, not just the files in the workspace.
- Blame is processed on file open, optionally on save, and cleared on close.
- Optional inline, status, or hover blame. Left by popular demand. Right too.
Extras
- Heatmap visualization, line, and file history.
- Interactive diff with command clickable location.
- .gitblame files open commits online at different urls.
- Editor button for all previous changes and interactive search.
- Includes some commands, settings, and menus available to explore.
Commands
- git-blame.commands.previousPatch
- gitBlame.fileView.refresh
- git-blame.diffView.refresh
- git-blame.diffView.setRef
- git-blame.diffView.setDir
- git-blame.diffView.showFile
- gitBlame.lineView.refresh
- git-blame.OpenCommitOnTheWeb
- git-blame.command.lineHistory
- git-blame.command.fileHistory
- git-blame.commands.showPatch
- git-blame.logView.refresh
- git-blame.logView.setAuthor
- git-blame.logView.toggleReflog
- git-blame.fileView.refresh
- git-blame.fileView.setAuthor
- git-blame.fileView.setRef
- git-blame.fileView.toggleReflog
- git-blame.diffView.diffAll
- git-blame.branchView.refresh
- git-blame.branchView.base
- git-blame.branchView.checkout
- git-blame.treeView.openLog
- git-blame.diffView.diffStat
- git-blame.treeView.openResourceUri
- git-blame.treeView.copyLabel
- git-blame.treeView.copyDescription
- git-blame.views.authors.refresh
- git-blame.views.search.query
- git-blame.views.search.compareFiles
- git-blame.editorContext.log
- git-blame.editorContext.diff
- git-blame.editorContext.patch
- git-blame.editorContext.web
- Git Blame: Apply Diff File (from base)
- Experimental and sometimes fails silently.
- git-blame.commands.commitDiffFile
- Git Blame: Show Diff File (from base)
- Pre-requisite for commitDiffFile to show the diff from a base.
- git-blame.commands.showDiffFile
- Show the log in chunks, allowing for checkout, copy, and more.
- git-blame.commands.quickPick.log
- Show the reflog, similar to the related log command.
- git-blame.commands.quickPick.reflog
- Show branches in descending order from the most recent commit.
- git-blame.commands.quickPick.branch
- Git Blame: Set Word Wrap Off For Inline Blame
- Inline blame works best when word wrap is off.
- git-blame.commands.setWordWrapOff
- git-blame.commands.tree.ref
- git-blame.commands.tree.files
- git-blame.commands.tree.up
- git-blame.commands.tree.activeEditor
- Git Blame: Interactive Search
- undefined
- git-blame.commands.interactiveSearch.menu
API
package.json
{ "extensionDependencies": ["solomonkinard.git-blame"] }
Get the commit id for the current line.
const id: string | undefined =
await vscode.commands.executeCommand("gitBlame.getShaForCurrentLine");
console.log(id);
Get the git commit ids whenever a line is focused.
vscode.commands.executeCommand("git-blame.commands.onShaForCurrentLine",
(ids: string[]) => console.log(ids));
Get the git commit ids whenever a file is focused.
vscode.commands.executeCommand("git-blame.commands.onAllShasForFile",
(ids: string[]) => console.log(ids));
Get the git commit ids for the file.
// 1-based array where each index is the sha for the line.
const ids: string[] = await vscode.commands.executeCommand(
"git-blame.api.getAllShasForFile");
console.log(ids);
Get the commits for the file.
vscode.commands.executeCommand(
"git-blame.commands.onShaListingIndexedByLine",
(shaForEachLine: string[]) => console.log(shaForEachLine));
Get commits for the commit ids.
const shaToCommitMap: Map<string, Commit> =
await vscode.commands.executeCommand("git-blame.commands.getAllCommits");
console.log(shaToCommitMap);
Commit type:
interface Commit {
sha: string;
date?: string;
author?: string;
mail?: string;
summary?: string;
previous?: string;
}
FAQ
- & VSCE: Git Blame: command 'git-blame.statusClick' not found
- & Inquiry about Git Web URL
- How to open commits online with multiple repositories and links?
- & How to use this extension?
- & How is logClickUrls supposed to work?
- & Git Blame: Line blame is not aligned properly
- & Git blame inline alongside code is not appearing
- & Extension source code
- & Feature: "Edit web url" should be a VS Code setting
- & Feature: "Open commit on the web" should open to the exact line
- & Feature: Put all commands in the command palette
- & Alignment inline blame causes unaligned blame in case of inlay hints
- & The floating box does not appear as expected.
- What about changes processed outside of IDE?
- There is a setting that does or does not start a new process for blame. If on, changes outside of the IDE should be picked up if the file is in the active editor when it's changed. Feel free to file a bug if and how you think this should be more robust.
- Where is the Git Blame menu?
- It's only available when a file is open. In order to use the sub-menus the file must reside on disk somewhere. The active file is the seed for many of the available menus. The git directory of that file will be used for some of the listings. That's why an active file needs to be available.
Features
Time Travel 🔮

Context Menu 👩🏾🍳

Blazing Fast ⚡️

Command Center 👨🏽🚀

Interactive Diff 📝

Inline Blame 🚁

Git Online 🌎

User Friendly 🐶

Line History 📜

Search 👀

Custom Urls 🧤

Right

Tree
Tree menu that allows you to explore an entire repository for a different branch or time, without changing the files in current working directory.

Body
Inline blame hover now includes the commit body.

Setting for hover on all lines or just the active line.

Custom URLs for Open Online
Put a “.gitblame” file in any directory between the file and the repository (inclusive). That allows for more customization, especially when working with multiple repositories at once. For example, the file below would open https://example.com/doc1/$ID, where $ID is the commit id.
.gitblame
{
"openOnline": {
"url": "https://example.com/$PROJECT/$ID",
"replacements": {
"$PROJECT": "doc1"
}
}
}
Bulk Edit
Experimental