Git History

Scroll through git log in a terminal Read every line's history beside your code

Git History is a free VS Code extension. Select a few lines, right-click a file or folder, or press Ctrl+Alt+H. You see each commit that changed it, its diff in an editor tab, and the files it touched.

code --install-extension vitalivu992.git-history-vsce

Works in VS Code 1.85+ and in editors that install from Open VSX (VSCodium, Cursor, Windsurf, Gitpod). MIT licensed.

VS Code with the Git History panel at the bottom listing commits, and the selected commit's README.md diff open side by side in an editor tab with removed lines in red and added lines in green.
The commit list and changed files sit in the bottom panel, beside Terminal. The selected commit's diff opens in an editor tab, side by side when there is room.

Four ways to open history

Start from the thing you are looking at. The panel shows only the commits that changed it.

  • A file

    Every commit that changed the open file, renames included.

    Right-click in the editor → Git History (File), or Ctrl+Alt+H
  • A few lines

    Only the commits that touched the selected lines, using git log -L.

    Select lines → right-click → Git History for Selection, or Ctrl+Alt+Shift+H
  • A file or folder in the Explorer

    Commits under that path. Diffs and changed files show only that path, in folder-tree order.

    Right-click in the Explorer → Git History
  • The whole repository

    The full branch log, loaded 500 commits at a time with a Load more row.

    Command Palette → Git History (Repository)

Selection history follows the lines, not the file

Select a block of code and ask who changed it. Commits that edited other parts of the file stay out of the list, so a 5-year-old file with 400 commits can come down to the six that matter.

The changed-files list and the diff are scoped to the tracked file, so the answer stays focused.

package.json open in VS Code with the version line selected; the Git History panel lists only the release commits that changed that line, with version tag badges.
The "version" line of package.json is selected. The panel lists only the release commits that changed it, with their tag badges.

The list stays put, the diff gets the room

  • Diff in an editor tab. One reusable tab, titled with the short hash and subject. It opens without taking focus from the list, so arrow keys keep moving through commits.
  • Changed files beside the list. GitHub-style status icons for added, modified, deleted, renamed and copied files. Click a file to scroll the diff to it.
  • Large repositories. Commits load in pages (gitHistory.maxCommits, 500 by default).
  • Readable rows. Author avatars, tag badges, relative dates with the exact time on hover, and expandable commit bodies.
Repository history: a commit that changed three files is selected, the changed-files list shows CHANGELOG.md, CLAUDE.md and FEATURES.md, and the editor tab shows all three diffs stacked.
Repository history. A commit that touched three files shows all three diffs in one tab, and the panel lists the files.

A diff viewer that fits the tab

The diff tab picks its own layout. It opens side by side when each side can show at least 120 characters per line, and unified when it cannot. Resize the tab and it decides again, until you click the toggle yourself.

Side-by-side diff with word wrap on: long lines wrap and each wrapped line takes the same height on the left and right, so line numbers stay level.
Word wrap (Alt+Z). A wrapped line takes the same height on both sides, so line 40 on the left stays level with line 40 on the right.
  • Compare any two commits. Shift+click two rows (or Shift+Enter) for the diff between them, for example v1.0 against v2.0.
  • Combine commits. Ctrl+click rows that are not next to each other to see their changes as one diff.
  • Compare with parent. Ctrl+Alt+P shows the focused commit against its first parent.
  • Ignore whitespace. The W button or Ctrl+Shift+Alt+J re-runs the diff with git's -w.
  • Stats bar. N files changed, +insertions, -deletions above every diff.
  • Folder-tree order. Diff sections follow the Explorer: sub-folders before files, natural number order.

Blame that stays out of the code

Press Alt+B in any editor. Each block of lines from the same commit gets the author and date, trailing the code.

  • Aligned in one column. Annotations start at column 160 (gitHistory.blame.annotationOffset). A line longer than that hides its annotation, so the text never sits on top of code.
  • From blame to the commit. Hover an annotation and click Show commit details, or click the status bar item, to open that commit in the Git History panel.
  • Start from the gutter. Right-click a line number for Show / Hide Git Blame Annotations.
  • Your date format. relative, short or iso through gitHistory.blame.dateFormat.

Act on a commit without leaving the list

Right-click a commit or a changed file. Commands that change your working tree ask before they run.

On a commit

Switch branch from the branch badge (right-click) or Ctrl+Alt+S: a searchable list of local and remote branches.

On a changed file

Links that work for your whole team

Commit and file links are built from your origin remote, over HTTPS or SSH, including SSH on a custom port.

  • GitHub
  • GitLab
  • Bitbucket
  • Azure DevOps

Keyboard shortcuts

Every list action has a key. Press ? in the panel to see them all. Shortcuts that would hide a VS Code default were moved to keys that do not.

In any editor
KeysAction
Ctrl+Alt+HGit History (File)
Ctrl+Alt+Shift+HGit History for Selection (needs a selection)
Alt+BToggle blame annotations
Move through commits
KeysAction
↑ ↓Previous / next commit
Home EndFirst / last commit
PageUp PageDownUp / down 10 commits
EnterShow the focused commit's diff
Shift+EnterSelect a range to compare
Ctrl+EnterAdd to or remove from the selection
Ctrl+ASelect all visible commits
Ctrl+LFocus the commit list
/ Ctrl+FFocus search
Ctrl+GJump to a commit by hash
Alt+PJump to parent commit
Ctrl+] Ctrl+[Next / previous tagged commit
?Keyboard help
EscapeClear selection, close dialogs
Diff tab
KeysAction
Alt+ZToggle word wrap
Ctrl+Shift+Alt+JToggle ignore whitespace
F5 Ctrl+Shift+RRefresh list and diff (also in the panel)
Search and filters
KeysAction
Alt+RRegex search
Ctrl+Alt+MMy commits only
Ctrl+Shift+QHide merge commits
Ctrl+Shift+3Newest / oldest first
Ctrl+Alt+QClear all filters
Copy and open
KeysAction
Ctrl+Alt+CCopy commit hash
Ctrl+Shift+7Copy short hash
Ctrl+Shift+ICopy commit info
Ctrl+Shift+Alt+RCopy the diff between two commits
Ctrl+Shift+LCopy commit URL
Ctrl+Shift+Alt+LOpen commit URL in browser
Ctrl+Alt+PCompare with parent
Git actions
KeysAction
Ctrl+Alt+KCherry-pick commit
Ctrl+Alt+RRevert commit
Ctrl+Alt+SSwitch branch
Ctrl+Shift+Alt+BCreate branch at commit
Ctrl+Alt+ICreate tag at commit
Ctrl+Alt+.Delete tag from commit

Settings

Seven settings, all optional. Toggles you flip in the panel (word wrap, ignore whitespace, regex, hide merges, my commits, sort order, search text) are remembered between sessions.

SettingDefaultWhat it does
gitHistory.defaultDiffViewautoauto opens side by side when each side fits 120 characters, otherwise unified. Also unified or side-by-side.
gitHistory.diffContextLines5Unchanged lines shown around each change (1–10).
gitHistory.maxCommits500Commits loaded per page, for the first load and each Load more.
gitHistory.hideMergeCommitsfalseStart with merge commits hidden.
gitHistory.commitList.dateFormatrelativeCommit list dates: relative, short or iso.
gitHistory.blame.dateFormatshortBlame dates: relative, short or iso.
gitHistory.blame.annotationOffset160Column where blame annotations start (1–1000).

Recent changes

Highlights from the changelog. The full changelog lists every fix.

  1. 1.2.9

    • Blame annotations trail the code at a fixed column
    • Blame hover with a Show commit details link
    • Show / Hide blame in the line-number menu
    • GitHub-style status icons in the changed-files list
  2. 1.2.7

    • Copy file URL at a commit
    • Changed-file actions work when the workspace is a sub-folder of the repository
  3. 1.2.4

    • Split layout: commit list in the bottom panel, diff in an editor tab
  4. 1.2.3

    • Git History moves into the bottom panel, beside Terminal
    • Pagination with Load more, compare with parent, copy range diff, open commit or file on your git host

Get started in a minute

  1. Install from the VS Code Marketplace or Open VSX, or search for "Git history for selection" in the Extensions view.
  2. Open a file in a git repository.
  3. Press Ctrl+Alt+H (Cmd+Option+H on macOS).

You need

  • Visual Studio Code 1.85 or later, or a compatible editor
  • Git on your PATH
  • A folder that is a git repository

Read more