Git Diff Panel (vdiff)
English | 简体中文

Open a Git diff in VS Code's native multi-file Changes editor directly from
a terminal, including over Remote-SSH. A small companion CLI sends a request;
the extension opens a dedicated review window with only the changed files, a
compact Explorer tree, single-column inline diffs, and next/previous navigation
that keeps working across files.
┌─ VS Code: repo (vdiff review) ─────────────────────────────┐
│ EXPLORER │ Changes (3) │
│ ▾ vdiff Changes │ ▾ src/api │
│ ▾ src/api │ client.ts +12 -3 │
│ client.ts M │ server.ts +8 -0 │
│ server.ts A │ single-column inline diff │
└────────────────────────────────────────────────────────────┘
The terminal command is vdiff; the Marketplace extension is
pr-g.git-diff-panel.
Why use it
- Terminal-first. Run
vdiff where you already are, including an SSH shell
on a remote machine. No code CLI IPC probing, no path juggling.
- Native Git diff. Files are rendered from the built-in Git extension's
virtual documents, not copied into temporary editor tabs.
- Dedicated review window. The extension opens a separate
.code-workspace with only an empty folder and sets
diffEditor.renderSideBySide: false, so the review is single-column and does
not disturb other windows.
- Only changed files. The Explorer shows a
vdiff Changes tree. The
project is not loaded just to display a diff.
- Compact tree. Single-child directory chains are collapsed, so
aa/bbb/ccc/file.ts appears as one row instead of three nested folders.
- Cross-file navigation. Clicking a tree item reveals that file in the
multi-file diff editor; the editor's next/previous controls continue across
the whole change set.
Requirements
- VS Code 1.80 or newer.
- The built-in Git extension.
- Remote-SSH is optional. When used, install the extension on the remote side
(VS Code does this automatically from the Marketplace).
- The bundled
vdiff CLI is a bash script, so local use outside a remote host
needs Linux, macOS, or WSL. The extension itself also runs on Windows, but
the CLI is not available in native PowerShell.
fzf is optional, only for vdiff -b, vdiff -t, vdiff -r, vdiff -s,
and vdiff -w.
Install
From the Marketplace
Search for Git Diff Panel (vdiff) in the Extensions view, or run:
code --install-extension pr-g.git-diff-panel
For Remote-SSH, run the command in a Remote-SSH terminal, or install it from
the Extensions view while connected to the remote.
The CLI install target follows the extension host: a local window installs it
into the local home, while a Remote-SSH window installs it into the remote
home. Install the extension in both contexts if vdiff is needed in both
terminals.
From a VSIX
code --install-extension git-diff-panel-0.7.9.vsix
From source
npm install
npm test
npm run package
./install.sh # package and install into VS Code / Remote-SSH
./install.sh --force # replace an existing install
Run ./install.sh on the machine where the extension host runs. For
Remote-SSH that is the remote machine. Reload the VS Code window afterwards
(Developer: Reload Window).
Companion CLI
The extension bundles bin/vdiff in the VSIX. On activation it installs:
~/.local/bin/vdiff (copy of the bundled script, refreshed on activation)
- bash completion in
~/.local/share/bash-completion/completions/vdiff
- zsh completion in
~/.local/share/zsh/site-functions/_vdiff
- fish completion in
~/.config/fish/completions/vdiff.fish
Make sure ~/.local/bin is on PATH, then run vdiff inside any Git
repository. If the CLI was not installed (for example because the workspace is
untrusted or vdiff.installCli is off), run the command
vdiff: Install/Update CLI, or install it manually:
install -m 0755 bin/vdiff ~/.local/bin/vdiff
To install shell completion directly from the CLI, run
vdiff --install-completion zsh (or bash / fish). The generated scripts
are self-contained and do not require Carapace or another completion framework.
The extension and the CLI must run on the same machine. For Remote-SSH, run
vdiff in the Remote-SSH integrated terminal (or another shell on the remote
host); for a local workspace, run it on the local machine.
vdiff # working tree changes
vdiff main # working tree vs main
vdiff main feature # main...feature (merge-base)
vdiff main..feature # explicit revision range
vdiff -b # pick one branch with fzf
vdiff -b -b # pick base and target branches
vdiff -t # pick one tag with fzf
vdiff -r # pick a branch, tag, or recent commit
vdiff -w # pick another worktree with fzf
vdiff -w -b # pick a worktree, then a branch
vdiff --reuse main # open in the receiving window
vdiff --window main # force a dedicated review window
vdiff -s main feature # pick changed files before opening
vdiff -f main feature # one native diff editor per file
vdiff -p main feature # write a .diff file and open it as text
vdiff main..feature -- src/ # limit the diff to a path
Branch, tag, and worktree pickers
-b and -t are repeatable. One selection compares the working tree with that
ref; two selections compare base...target using the merge base:
vdiff -b # fzf list of local and remote branches
vdiff -b -b # first pick = base, second pick = target
vdiff -t -t # same for tags
-r combines local branches, remote branches, tags, and the most recent 50
commits in one picker.
-w lists git worktree list entries, including the current worktree and
detached worktrees. The diff then runs entirely inside the selected worktree,
and the review request points at that worktree's path.
Open modes
vdiff.openMode controls where a request is shown:
dedicated (default): open a new review window with only the changed files.
reuse: handle the request in the window that receives it, without opening
a new window.
Dedicated review windows are minimal by default: the activity bar, primary and
secondary side bars, status bar, tabs, breadcrumbs, minimap, and layout controls
are hidden, and the multi-diff editor's built-in file list is switched to
View as Tree on the right. Set vdiff.review.minimalUI to false to keep
the normal VS Code chrome.
The first review window for a repository asks you to trust the generated
review workspace. VS Code remembers that trust for later windows of the same
repository. Trust is required for the built-in Git extension.
The CLI flags override the setting per invocation:
vdiff --reuse main feature
vdiff --window main feature
In reuse mode, every VS Code window watches the queue. The first window to
atomically claim the request handles it, which is normally the window whose
terminal you used. With many windows on the same machine, dedicated is more
predictable.
Shell completion
The CLI can print completion scripts directly:
vdiff --completion bash
vdiff --completion zsh
vdiff --completion fish
The extension installs them automatically when possible. For zsh, make sure the
user site-functions directory is in fpath:
fpath=(~/.local/share/zsh/site-functions $fpath)
autoload -Uz compinit && compinit
What the extension opens
For a dedicated request, the extension:
- Atomically claims the request file from
~/.cache/configfiles/vdiff/requests/.
- Generates a workspace under
~/.cache/configfiles/vdiff/workspaces/ that
contains only an empty folder and sets diffEditor.renderSideBySide: false.
- Opens that workspace in a new window.
- In the review window, opens the native multi-file diff editor with the
changed files and fills the
vdiff Changes Explorer view.
For a reuse request, steps 2–3 are skipped and the receiving window opens the
diff directly.
-f switches to one vscode.diff editor per file. -p skips the extension
and opens a plain .diff file as text.
Commands
vdiff: 检查插件状态 (vdiff.ping) shows the loaded version, review
workspace path, and workspace folders.
Open Diff (vdiff.openFileDiff) is used by the change tree and is normally
not invoked directly.
How it works
The CLI writes a NUL-separated VDIFF2 request:
VDIFF2 <panel> <repo> <title> <emptyTree> <count> <openMode>
per file: <leftRef> <rightRef> <leftPath> <rightPath> <title>
panel is changes or diff.
openMode is reuse, dedicated, or empty (use the vdiff.openMode
setting).
~ means the index; an empty ref means the real working-tree file; - means
the empty-tree side of an add or delete.
The extension uses the built-in Git extension's toGitUri and the same
internal multi-file diff command as the Git extension
(_workbench.openMultiDiffEditor). If that internal command is unavailable in
a future VS Code release, it falls back to per-file vscode.diff editors.
The extension has no telemetry and makes no network requests. It reads local
request files and talks to the built-in Git extension.
Troubleshooting
vdiff Changes is missing. Reload the window, then run
vdiff: 检查插件状态 and confirm the version.
- The request goes to the wrong window or is ignored. Check
~/.cache/configfiles/vdiff/extension.log. The extension logs activation and
request handling there.
- An old
local.vdiff-panel is still installed. Uninstall it and reload.
Two extensions listening to the same queue will race for requests.
- Remote-SSH. Install the extension from the Marketplace in the Remote-SSH
window (or run
code --install-extension pr-g.git-diff-panel in the remote
terminal), then run vdiff from the Remote-SSH integrated terminal. The CLI
is installed on the remote on activation; ./install.sh is only for source
builds.
- No fzf.
-b, -t, -r, -s, and -w need fzf; plain revision
arguments do not.
vdiff: command not found. Check ~/.local/bin is on PATH, or run
vdiff: Install/Update CLI.
vdiff <base> stage fails. stage is not a Git revision. Use
vdiff <base> for the working tree, or git diff --cached <base> for the
index.
- Local workspace sees nothing. The CLI writes to the home directory of the
machine it runs on, and the extension reads the home directory of the
extension host. Run both on the same side (local or remote).
Development
npm ci
npm test
npm run package
The test suite runs with Node's built-in test runner and mocks the vscode
module, so it does not need a VS Code instance. Release automation is described
in docs/PUBLISHING.md.
License
MIT