ExDiff
English | 简体中文
Visual Studio Marketplace · GitHub source
Review Git changes in VS Code without losing your editor smarts. ExDiff opens any two revisions of a file as real files on disk, so hover, Go to Definition, Find References, Find Implementations and diagnostics keep working on both sides of the diff.
Why ExDiff
VS Code's built-in Git diff shows the older revision as a virtual git: document. It is not on disk and does not belong to any workspace folder, so the language server ignores it:
- no hover, no
F12, no Find References;
- no lint or type diagnostics;
- no navigation into the old version of the code.
ExDiff materializes each revision as a real snapshot inside the repository and adds it to the workspace. Both sides of the diff become ordinary file:// documents, and your language server treats the old revision exactly like normal source code.
Built-in diff: [ virtual git: document ] → no language server → [ working file ]
ExDiff: [ real snapshot file ] → language server ✅ → [ working file ]
Diffing is strictly read-only: ExDiff never modifies your working tree, index, refs or reflog in the background. Explicit Checkout PR / Branch for Review… and Review Worktrees commands only fetch or manage worktrees when you invoke them.
Features
- Language features on both sides — hover, Go to Definition (including Go to Definition in Diff), Find References, Find Implementations (where supported) and diagnostics.
- One-click PR / branch review & worktrees — fuzzy-pick a GitHub PR, remote branch or local branch from the Review Worktrees view, check out into an isolated Git worktree or locally, and auto-resolve its exact base ref via
<gitdir>/exdiff-state.json without dirtying git status.
- Full review toolkit — GitHub-style "Viewed" checkboxes (in place by default or optionally folded, auto-resetting when modified), persistent file highlights, inline code-block review comments with clean Markdown export, tree/list toggle, and Open File in Working Tree with cursor line mapping.
- Read-only snapshots & one-click restore — automatically locks
.exdiff snapshot editors read-only per session to prevent accidental edits, with one-click restore.
- Branch, amend, rebase & staged comparisons — fork-point base comparison,
HEAD~1 ↔ HEAD, last git commit --amend, git range-diff rebase review, HEAD ↔ index, and any two refs.
- No telemetry — zero background network calls or telemetry.
Requirements
- VS Code 1.85 or newer.
- Git on
PATH (or point exdiff.gitPath at the executable).
- Optional: GitHub CLI (
gh) for listing open PRs and auto-detecting PR target branches in Checkout PR / Branch for Review….
- A language server that supports multi-root workspaces. TypeScript/JavaScript, Go and Python work out of the box; see Limitations for Rust, C/C++ and others.
Install
- Marketplace: install ExDiff from the Visual Studio Marketplace.
- VSIX:
code --install-extension exdiff-0.3.1.vsix
Reload the window after installing.
Quick start
- Open a Git repository in VS Code.
- Open a file, right-click it, and choose ExDiff: Open Changes with Base (or run it from the Command Palette).
- Hover, press
F12, or press Shift+F12 on the left-hand (old) side.
The first time, VS Code asks whether to add the snapshot folder to the workspace. Choose Add — this is what makes language features work on the old revision. The answer is remembered.
Commands
| Command |
What it does |
| ExDiff: Open Changes with Base |
Current file vs the merge-base (fork point) of exdiff.baseRef and HEAD. With the default auto, ExDiff finds the branch's creation point or nearest branch fork. The right side is the working tree or HEAD, depending on exdiff.rightSide. |
| ExDiff: Open Changes with Previous Amend |
HEAD@{1} vs the current version. Useful right after git commit --amend. Asks for confirmation when the last reflog entry is not an amend. |
| ExDiff: Open Changes with Previous Commit |
HEAD~1 vs HEAD. Shows exactly what the latest commit changed, ignoring settings and uncommitted edits. |
| ExDiff: Open Changes with HEAD (uncommitted) |
HEAD vs the working tree, including unstaged and untracked changes. |
| ExDiff: Open Changes with HEAD (staged only) |
HEAD vs the index, so only staged changes are shown. |
| ExDiff: Show Changed Files |
Focuses the Changes view for the current repository. |
| ExDiff: Show Amend Changes |
Focuses the Amend Changes view for the current repository. |
| ExDiff: Compare Two Refs… |
Picks any two branches, tags, commits or reflog entries and lists the changed files. |
| ExDiff: Checkout PR / Branch for Review… |
Fuzzy-pick a GitHub PR (number, URL, or open PRs via gh), remote branch or local branch, check it out in an isolated Git worktree or locally, record its base ref in <gitdir>/exdiff-state.json without dirtying git status, and open it for review. |
| ExDiff: Manage / Remove Review Worktrees… |
Lists linked Git worktrees so you can reopen, safely remove, or prune them after finishing a review. |
| ExDiff: Show Rebase Changes |
Detects the last rebase and shows git range-diff commit pairs with per-pair patches. |
| ExDiff: Open Base Version of This File |
Opens the base revision as a normal editor, with the full language server. |
| ExDiff: Open File in Working Tree |
Opens the real working-tree file from a changed-file item, diff editor, snapshot file or rebase patch, mapping the current cursor line to the corresponding working-tree line. |
| ExDiff: Go to Definition in Diff |
Jumps to the definition of the symbol under the cursor inside the active Changes / Amend Changes diff when the target file is part of the comparison, falling back to normal Go to Definition otherwise. |
| ExDiff: Mark File as Viewed / Unviewed |
Marks or unmarks the current file as reviewed (also via the sidebar checkbox or diff title bar). Keeps files in place by default, or optionally folds viewed files into a collapsible Viewed (N) group, and auto-resets if the file is later modified. |
| ExDiff: Mark File as Viewed and Open Next |
Marks the current file as viewed and immediately opens the next unviewed file's diff. |
| ExDiff: Open Next Unviewed File |
Opens the next unviewed file in the active Changes / Amend Changes view. |
| ExDiff: Mark All Files as Viewed / Clear All Viewed Marks |
Bulk-marks every changed file as viewed or clears all viewed marks for the current comparison. |
| ExDiff: Toggle Fold Viewed Files |
Switches between folding viewed files into the collapsed Viewed (N) group and showing them inline with checkboxes. |
| ExDiff: Highlight File / Remove Highlight |
Highlights important changed files (★) to revisit later. Persists across edits and commits until cleared or the file leaves the diff. |
| ExDiff: Clear All Highlights |
Clears every highlighted file mark in the current comparison. |
| ExDiff: Add Review Comment |
Opens an inline review comment thread anchored to the selected line or code block (also via the gutter + button). |
| ExDiff: Export Review Comments / Export to Clipboard |
Opens all code-block review comments in an editable Markdown editor (Export Review Comments in … menu) or copies them directly to the clipboard (Export Review Comments to Clipboard title-bar icon). |
| ExDiff: Clear File Comments / Clear All Review Comments |
Clears all review comments for a single file or for the entire repository. |
| ExDiff: Restore Snapshot File |
Reverts an accidentally modified file inside .exdiff back to its clean Git revision without touching the working tree. |
| ExDiff: Swap Sides |
Swaps the two sides of the current comparison. |
| ExDiff: Set Base Ref… |
Picks a base branch/ref (or Auto-detect) and saves it to exdiff.baseRef. |
| ExDiff: Refresh |
Re-reads the Changes, Amend Changes, Rebase Changes and Review Worktrees views. |
| ExDiff: Attach Snapshots |
Adds existing snapshot folders to the workspace. |
| ExDiff: Detach Snapshots |
Removes snapshot folders from the workspace without deleting them. Useful to remove duplicate Find References hits. |
| ExDiff: Delete Snapshots |
Removes and deletes all snapshots for the repository. |
| ExDiff: Prune Stale Snapshots |
Deletes snapshots older than exdiff.snapshotRetentionDays after confirmation. |
Where to find the commands
- Command Palette — press
Ctrl+Shift+P and type ExDiff.
- Changes / Amend Changes list — hover any changed file row for inline Highlight (
☆/★) and Open File in Working Tree buttons (or right-click the item).
- Editor title bar — compare with base and open the base version in normal files; open the working-tree file at the corresponding line, toggle Highlight (
☆/★), and toggle Viewed when viewing a diff or snapshot.
- Editor context menu — high-frequency actions (Open File in Working Tree, Go to Definition in Diff, Add Review Comment, Mark File as Viewed) at the top, with secondary commands grouped under ExDiff: More….
- Explorer context menu — on files: compare with base.
- Activity Bar — the ExDiff icon opens Changes, Amend Changes, Rebase Changes and Review Worktrees views.
Views
Changes
Lists every file changed since the fork point (the merge-base of exdiff.baseRef and HEAD), with its status (added, modified, deleted, renamed…), line counts and rename mapping. Click a file to open a diff whose two sides are real files, toggle between flat list and compacted directory tree layout, and check files (or entire folders) off as Viewed (in place by default, with a title-bar toggle to fold viewed files into a collapsible Viewed (N) group). If a viewed file is modified later (by a working-tree edit, new commit, amend or rebase), its viewed mark automatically resets and flags the file as Updated. The view refreshes on save, window focus, configuration changes and Git ref/index updates.
Amend Changes
Lists the files changed by the last git commit --amend (HEAD@{1} ↔ HEAD). Click a file to open a real-file diff of the amend. If the last HEAD update was not an amend, the view says so instead of showing a stale comparison.
Rebase Changes
After a rebase, lists the commit pairs reported by git range-diff:
| Marker |
Meaning |
= |
unchanged |
! |
rewritten (the patch shows what changed, including conflict resolution) |
< |
only in the old range |
> |
only in the new range |
Select a pair to read its patch, or open the full range diff.
Review Worktrees
Dedicated sidebar panel for one-click PR/branch review checkouts and worktree management. When no linked worktrees exist, displays a prominent Checkout PR / Branch for Review… button; once review worktrees exist, lists every linked worktree with its branch/commit, recorded base ref, dirty indicator, and one-click Open / Remove actions, plus a header Checkout PR / Branch for Review… button. Base ref hints are stored in <gitdir>/exdiff-state.json (inside .git/, invisible to git status) so exdiff.baseRef: "auto" resolves the exact PR/branch diff without editing .vscode/settings.json.
Settings
| Setting |
Default |
Description |
exdiff.baseRef |
auto |
Base branch or revision. auto checks <gitdir>/exdiff-state.json for a review base hint first, then reads the current branch's creation reflog (branch: Created from …), then uses the nearest merge-base among local and remote branches (including default branches), then HEAD~1. The diff starts at the merge-base (fork point) with HEAD. |
exdiff.snapshotDir |
${repoRoot}/.exdiff |
Where snapshots are stored. Supports ${repoRoot}, ${repoParent}, ${repoName} and ${slot}. The default lives inside the repository and is self-ignored, so git status stays clean. Deleting the repository also deletes this folder. |
exdiff.autoAttach |
ask |
Whether snapshot folders are added to the workspace automatically: ask, always or never. |
exdiff.rightSide |
workingTree |
Right side of the diff: the working tree (includes uncommitted changes) or the HEAD snapshot. |
exdiff.gitPath |
git |
Path to the Git executable. |
exdiff.maxFilesInTree |
2000 |
Maximum number of files listed in the Changes view. |
exdiff.snapshotRetentionDays |
7 |
Snapshots older than this are pruned. At startup only temporary ref-* snapshots are pruned; the Prune command removes all expired snapshots. 0 disables pruning. |
exdiff.readonlySnapshots |
true |
Automatically sets snapshot editors read-only in the current session to prevent accidental edits inside .exdiff. |
exdiff.reviewWorktreeDir |
"" |
Base directory for review worktrees created by ExDiff: Checkout PR / Branch for Review…. Supports ${repoParent}, ${repoName} and ${repoRoot}. Empty defaults to ${repoParent} (sibling folder). |
Typical workflows
Review a branch since it diverged
Open Changes with Base compares from the fork point — git merge-base <baseRef> HEAD — so it shows only the commits on your branch, not changes that landed on the base branch after you diverged.
- Run ExDiff: Open Changes with Base.
- The left side is a real checkout of the fork point; the right side is your working file.
- Use hover,
F12 and Find References on either side.
With the default auto, ExDiff reads the current branch's creation entry (branch: Created from …), falls back to the nearest merge-base among local and remote branches, then HEAD~1. This works for any parent branch (for example team/feature-a), not just main or master. Set exdiff.baseRef to a branch to override.
If you want to ignore uncommitted changes, set exdiff.rightSide to ref.
Review exactly the latest commit
Run ExDiff: Open Changes with Previous Commit. This compares HEAD~1 and HEAD only, regardless of your settings or uncommitted edits.
Work with an amend loop
git commit --amend.
- Run ExDiff: Open Changes with Previous Amend.
- The left side is the pre-amend commit (
HEAD@{1}); the right side follows exdiff.rightSide.
Review a rebase
git fetch upstream && git rebase upstream/master.
- Run ExDiff: Show Rebase Changes.
- Open a commit pair to see how the patch changed. Pairs marked
! were rewritten — often because of conflict resolution.
The detected ranges are cached per repository, so the review survives a window reload.
Review only staged changes
Run ExDiff: Open Changes with HEAD (staged only). The index is materialized with git write-tree, so unstaged edits are excluded.
Compare arbitrary revisions
Run ExDiff: Compare Two Refs… and pick two branches, tags, commits or reflog entries. The Changes view switches to that comparison.
One-click PR or branch review
- Open the Review Worktrees view in the ExDiff Activity Bar and click Checkout PR / Branch for Review….
- Filter a local/remote branch, pick an open GitHub PR (when
gh is installed), or type a PR number / URL (e.g. #123).
- Choose Checkout in Git Worktree (keeps your current working tree untouched) or Checkout in Current Repository, confirm the folder, and open it in a new or current window.
- ExDiff records the target base ref in
<gitdir>/exdiff-state.json (clean git status) so exdiff.baseRef: "auto" opens the exact PR diff immediately. When done, remove the worktree directly from Review Worktrees.
How it works
- ExDiff materializes a revision into
<repoRoot>/.exdiff/<snapshot> using a temporary index and git checkout-index. The snapshot contains no .git, so it is not treated as another repository.
- The snapshot folder is added to the workspace with
vscode.workspace.updateWorkspaceFolders(). That is what makes the language server index it.
- Snapshots are updated incrementally when the revision changes, and reused when it does not.
- Long-running background tasks (snapshot materialization and multi-batch incremental updates, snapshot deletion/pruning, PR/remote fetches, worktree creation/updates/removal, ref listing and
git range-diff) show cancellable progress notifications: clicking Cancel terminates the active git/gh process tree immediately and leaves snapshots/worktrees in a clean, recoverable state.
- The
.exdiff folder carries its own .gitignore, so the snapshots, sidecars and temporary files never appear in git status.
- Base comparison uses the merge-base (fork point) of
exdiff.baseRef and HEAD; auto checks <gitdir>/exdiff-state.json first, then the branch reflog creation point or the nearest branch fork, so upstream commits do not leak into the diff.
- Diffing never writes to your working tree, index, refs or reflog (
git write-tree only creates an unreachable tree object for staged-only comparison). Explicit Checkout PR / Branch for Review… and Review Worktrees commands only fetch or create/remove worktrees when invoked.
Limitations
- Duplicate Find References — the snapshot and the real repository both contain the code, so references appear twice. Run Detach Snapshots when you are not reviewing.
- Multi-root language servers — TypeScript/JavaScript, Go and Python work well. Rust (
linkedProjects), C/C++ (compile_commands.json) and some JVM/Kotlin servers need extra configuration, and cross-snapshot navigation is not guaranteed.
- Disk and memory — each snapshot is roughly the size of the tracked files, and every attached snapshot adds another LSP index. Use Detach Snapshots or Delete Snapshots to reclaim space.
- First materialization is slow on large repositories. Later updates are incremental, and an unchanged revision is reused.
- Submodules are not materialized; their entries appear as empty directories.
- Single-folder workspaces — adding the first snapshot folder may restart the extension host (VS Code behavior when a single-folder workspace becomes multi-root). The diff tab is restored; re-run the command if it was interrupted. Saving a multi-root
.code-workspace avoids this.
- Diff editor features — peek, some rename refactorings and some code actions are still more limited than in a normal editor. Use Open Base Version of This File for the full experience.
- Snapshots are disposable — manual edits are not detected. Delete the snapshots to rebuild them.
- Cleanup — temporary
ref-* snapshots are pruned at startup after exdiff.snapshotRetentionDays (default 7). Prune Stale Snapshots removes all expired snapshots. Detach only changes the workspace; Delete removes files from disk.
- Snapshots inside the repository — tools that scan the whole working tree (some linters, test runners or build scripts) may also visit
.exdiff. Add .exdiff to their ignore configuration if necessary, or point exdiff.snapshotDir at a folder outside the repository.
Troubleshooting
| Symptom |
What to do |
The old side has no hover, F12 or diagnostics |
The snapshot folder is not part of the workspace. Run ExDiff: Attach Snapshots, or set exdiff.autoAttach to always. |
| “Not in a Git repository” |
The file is outside any repository, or the repository is bare. Check that git rev-parse --show-toplevel works; set exdiff.gitPath if Git is not on PATH. |
| “Base ref not found” |
The repository has no parent commit, or exdiff.baseRef is invalid. Use ExDiff: Set Base Ref… to pick HEAD, a branch or a commit. |
| “No commits yet” |
Create the first commit, then run the command again. |
| Find References shows two hits |
Expected: one in the snapshot, one in the real repository. Run ExDiff: Detach Snapshots when you are done reviewing. |
| A snapshot does not match the revision |
The snapshot was edited manually. Run ExDiff: Restore Snapshot File for a single file, or ExDiff: Delete Snapshots and open the diff again. |
| “Unable to add the snapshot folder to the workspace” |
The workspace file is read-only, the folder is already present, or the workspace is untrusted. Add the folder manually or make the workspace writable. |
| ExDiff: Show Rebase Changes finds nothing |
It needs ORIG_HEAD and a rebase (start) reflog entry. A later operation may have overwritten ORIG_HEAD; use Compare Two Refs… with the two ranges instead. |
| Snapshots use too much disk |
Run ExDiff: Delete Snapshots, lower exdiff.snapshotRetentionDays, or delete <repoRoot>/.exdiff manually after detaching. |
| The first diff on a large repository is slow |
The initial checkout is a full materialization. Later updates are incremental; exdiff.snapshotDir can point at a faster disk. |
Language
ExDiff ships with English and Simplified Chinese UI strings. It follows VS Code's display language; switch with Configure Display Language and restart. Other languages fall back to English.
Privacy
ExDiff has no telemetry, makes no background network requests, and never uploads your code. Network access only happens when you explicitly run Checkout PR / Branch for Review… (via your local git / optional gh CLI).
License
MIT © 2026 xaxys. See LICENSE.
| |