Skip to content

Diffs and Git Diff

An agent just touched twelve files. Before you commit, you want to see each change the way a pull request shows it, keep the good parts and throw out the rest. The Git Diff tab does that next to the terminal where the agent is still running: the changed files on the left, their diff on the right.

A diff tab “diff.txt ↔ HEAD”: All Changes, Unstaged and Staged at the top, +2 −2, “1 of 2” with arrows, and Revert Hunk. The old version on the left and the new on the right, with the changed words marked in red and green.

Git › Git Diff (⌃⌘G) opens the repository’s changes in one tab. Git Diff in the branch popup opens it too, and so does a click on the +41 −10 at the top of the project sidebar, on what those count: the changes not committed yet.

  • The changed files, on the left, as a tree of only the folders that hold changes, all open. Each file has its icon, its +12 −3, and A, D or R when it was added, deleted or renamed. ↑ and ↓ move from file to file; ↩ goes to the diff.
  • A file’s diff, on the right, is the one described below. Under Uncommitted (and All changes on the base branch) it has everything: All Changes, Unstaged and Staged, the hunk buttons, Send to Agent. Under All changes on another branch, or a commit, it is read-only. Past its last change, the arrow goes on to the next file’s first one (and back the other way), and the list follows.
  • All files, above the files, shows every file’s diff on one page: a header row for each (its name and folder, +/−, a chevron that folds it away, and buttons to open the file or show it side by side), then its lines, unified. Long unchanged runs are folded into rows like “67 unmodified lines”: click one to see them. Collapse All folds every file away. A file with a very large diff, or very long lines (a minified file), says so, with Show anyway. The page is laid out as you scroll, so a large change stays quick, and it keeps its place, its folds and what you collapsed while you look at one file.

Under the files, choose what to compare:

  • All changes: everything your branch changed since it parted from its base, committed or not, together. The base is the default branch of your upstream’s remote (origin/main), else main or master. It is named at the top of the tab, main → feat/login: click it to count from another branch, which Next Term remembers for the repository. On the base branch itself, All changes is what isn’t committed yet.
  • Uncommitted: the files on disk and the index against the last commit. It is listed while there is something uncommitted.
  • A commit: your branch’s commits since its base, newest first, with the hash, author and date, 100 at a time as you scroll (on the base branch, its history). Select one for the files it changed, each against the commit before.

The tab reads the repository again when it changes: an agent’s next edit, a commit, a stage. The file you were on stays selected, scrolled where it was, with the folds you opened still open. A file that is no longer changed leaves the list, and the selection moves to the one after it.

The button at the top left hides the file list, and brings it back; drag its edge to resize it. Next Term remembers both. Git Diff only reads, with --no-optional-locks, so it never holds the index lock while your git commands, or your agents’, run. An agent’s proposed edits and the Git Log’s commit diffs still open in tabs of their own.

  • Press ⌥⌘G (View › Show Changes) to see the changes of the file you are editing. The Git Diff tab opens on it, under Uncommitted, with the other changed files beside it.
  • In the project sidebar, select a changed file and press ⌥⌘G, or right-click it and choose Show Changes.
  • In the editor, click a change mark in the gutter.

The file has to be in a git repository: changes are shown against the last commit.

The switch at the top of every diff, Side by Side | Unified, chooses how it shows; View › Diffs & Blame › Unified Diffs does the same. One choice holds for every diff, an agent’s proposed edit and a past commit’s included, and Next Term remembers it.

  • Side by Side: the old version on the left, the new on the right, rows aligned.
  • Unified: one column, top to bottom. Removed lines are on red with − and their number in the old file, the lines that replace them on green with + and their number in the new one, with the unchanged lines between. Long unchanged runs are folded into rows like “26 unmodified lines”, and a click shows them.

In Unified, the hunk buttons act on the current change, the one “2 of 3” names and the gutter marks: selecting lines or clicking a row makes their change the current one, and so do the arrows and scrolling. Right-click a row for Stage Hunk, Unstage Hunk or Rollback Hunk on that row’s change, whatever else is selected, Send to Agent and Copy.

  • Old on the left, new on the right (side by side), rows aligned so a changed line sits next to its old self.
  • Removed lines are tinted red, added lines green, and the words that changed within a line are marked more strongly, in both views.
  • Syntax-coloured with the editor’s grammars; side by side, both sides scroll together.
  • The header shows the file, its folder, and the + and − line counts.
  • Step through the changes with the arrows (“1 of 2”). Scrolling also picks the change at the top of the view, and clicking a row picks its change.
  • The diff refreshes by itself when the file or the git index changes: an agent’s next edit, a commit, a stage.

The switch at the top chooses what to compare:

ViewComparesTab title
All ChangesThe file on disk against the last commitfile ↔ HEAD
UnstagedThe file on disk against the indexfile ↔ Index
StagedThe index against the last commitfile ↔ HEAD

In the Git Diff tab, a file under All changes is read-only: the file on disk against where your branch parted from its base, titled like app.txt ↔ main (its tooltip names that commit). A branch’s diffs open from the branch popup, read-only too: file @ feat/x is what that branch changed since it parted from yours, and file ↔ feat/x is the file on disk against that branch. See Compare a branch.

Act on the current change (the hunk) with the buttons on the right:

  • Stage Hunk (in Unstaged) adds just those lines to the index, like git add -p.
  • Unstage Hunk (in Staged) takes them out again.
  • Rollback Hunk (in All Changes and Unstaged, also ⌥⌘Z while the diff has the keyboard) puts those lines back the way they were, at once, and the next change becomes the current one: the notice that follows has Undo, and so has ⌘Z. To roll back a whole file, use Git › Rollback… (see Roll back a file’s changes).

You build a clean commit out of an agent’s work one hunk at a time, without leaving the window and without remembering git add -p’s keys.

Lines you select in any diff (a file’s diff tab, the Git Diff tab side by side, Unified or All files, a commit’s diff, an agent’s proposal) reach the agents linked to that window the way an editor selection does: Claude Code shows them as selected. The side that counts is the one you clicked or selected in last. New-side lines go as the file’s real line numbers, removed lines as their text with the caret where they used to be, and a commit’s or staged version as text only. .env and key files are never shared.

Press ⌥⌘K (Agents › Send to Agent) to type them into the agent’s prompt. From the new side (the right), or the Unified column, the agent gets the file at those lines in its own syntax, as from the editor (@app/User.php#L10-20 for Claude Code, app/User.php:10-20 for Codex). From the old side, it gets the removed lines as quoted code with the file’s path, since they aren’t in the file any more. Nothing is sent until you press ↩︎ there. With nothing selected, the file is sent.

While you have uncommitted lines selected and an agent runs in the window, the diff’s toolbar shows a quiet ⌥⌘K Ask Claude Code (or Codex, Gemini CLI, …) that does the same. It never shows for .env or key files. See Send to Agent.

  • Staged: the index isn’t the file on disk, so the reference says “(as staged)” and the selected lines are pasted after it.
  • A past commit: the reference says “(as of commit 4cc062d)”, with the selected lines pasted after it.
  • Removed lines only: select red lines on the old side and they are pasted after the reference, which says “(lines removed)”: the file no longer has them.
  • A deleted file is sent as “(deleted)”, with any lines you select pasted after it.
  • An agent’s proposed edit: nothing is sent. The agent is waiting for your answer in its terminal; accept or reject first.

Lines pasted from two changes at once have a ⋯ line where the diff skips the unchanged lines between them. More than 200 lines (or 16 KB) are not pasted: the reference goes alone, and a selection of removed lines that large sends nothing.

Read an agent’s changes the way you’d review a pull request, then hand it every note at once.

  • Comment on lines. Select lines in an uncommitted diff and click Comment in the diff’s toolbar, or choose Add Review Comment… from the diff’s right-click menu when the toolbar has no room. Write what should change.
  • Commented lines are marked in the side-by-side diff, the Unified view and the All files page, and Review (N) in the toolbar counts the window’s comments. Side by side and Unified show each comment’s note right after its line; an outdated one shows none.
  • Comments follow their lines as the agent keeps editing the file. When the lines themselves change, the comment stays and says it is outdated.
  • Review lists the comments, to edit them, discard them, or send them all to the agent in that window as one prompt. Each one goes with its file, lines and the code it was about. The right-click menu has Review (N)… too.
  • The draft stays with the window while it’s open; closing the window or quitting Next Term discards it.

Agents keep editing while you review. Each hunk action first checks that the file, or the index, is exactly what the diff was made from, by its full git blob id. If anything changed in the meantime, nothing is touched: Next Term tells you, refreshes the diff, and you try again on what is really there. (Plain git apply would place a stale hunk at an offset instead of failing.)

Other guards:

  • Unsaved edits: reverting a change in a file with unsaved edits in the editor is refused until you save or close it.
  • Git is busy: if another git command holds the index lock (an agent committing, say), Next Term says so; try again in a moment.
  • Undo is careful too: ⌘Z after a revert restores the file only if nothing changed it since.

When Claude Code, Gemini CLI or Qwen Code proposes an edit, it opens in the same kind of diff tab with Accept (⌘↩︎) and Reject instead of the hunk buttons. See Proposed edits open as a diff.

In the Git Log, double-click a file in a commit’s changed files to see what that commit did to it, against the commit before. The tab is titled like app.txt @ 4cc062d and is read-only: a commit never changes, so there is nothing to stage or revert.

Coming soon Staging selected lines, and editing the proposed side of an agent’s change before you accept it.