Changes
Reading the diff
16 min read
The diff shows what changed in a file: the removed lines in red, with −, and the added ones in green, with +, with a few unchanged lines around them for context. In Versora, the same viewer is used for local changes (unstaged, staged, new file), for the files of a commit and for comparisons.
This page explains how to open and read the diff and each option on the bar. Staging from the diff is in Staging; discarding, in Discarding changes.
- Local changes: click a file in the changes panel.
- A commit's file: select the commit in the graph and click the file in the right panel's list.
- Comparisons: the comparison of a commit with the working directory and the diff between two commits use the same viewer (see Comparing).
- The diff opens in the central area, in place of the graph.
- Click the file. The diff opens and the file's row stays marked in the list.
- Read it from top to bottom, or use the bar's Previous change and Next change arrows to jump from block to block.
- To close it: click the same file again, press Esc with the focus on the diff, or click the X ("Close (Esc)").
| Part | What it shows or does |
|---|---|
| Folder and name | The file's path (the tooltip shows the full path). |
| Mode | Where the diff comes from (table below). |
| +12 −3 | How many lines were added and removed. It doesn't appear in an image diff. |
| Owners | The file's owner according to CODEOWNERS, when the repository has one (see Checks). |
| Blame / History | Open the blame and the file history. On a new file they're disabled ("The file isn't in Git yet (untracked)."); Blame is too, on a binary or an image ("Blame only applies to text files."). |
| Stage file / Unstage file | Only on local changes (see Staging). |
| External tool icon | "Open in external diff tool" (see git mergetool and git difftool). Disabled on a new file: "New file: there's no previous version to compare with". |
| X | "Close (Esc)". |
The text next to the name says what's being compared:
| Mode | What it compares | Equivalent command |
|---|---|---|
| unstaged | The stage with the file on disk: what you changed and haven't staged yet. | git diff -- file |
| staged | HEAD with the stage: what goes into the next commit. | git diff --cached -M -- file |
| new file | Nothing with the file on disk: a file git doesn't track yet. | git diff --no-index -- /dev/null file |
| in commit | The commit with its first parent (on the repository's first commit, with nothing). | git diff -M <parent> <commit> -- file |
| commit × working directory | A commit with the file on disk. | git diff -M <commit> -- file |
| between two commits | Any two commits, for example from the multiple selection in the graph. | git diff -M <from> <to> -- file |
The -M makes git recognize renamed files.
- Green background and +: added line. Red background and −: removed line. No color: context.
- Syntax highlighting by the file extension (TypeScript, Rust, C#, YAML, SQL and many others).
- Changed part within the line: when a removed line is followed by its new version, the part that changed is highlighted in both. If almost the whole line changed, there's no extra highlight.
- Line numbers on the left: the old version's and the new one's.
Only reads: the diff is requested from git according to the mode (table above), with the chosen
number of context lines (-U) and, with Ignore whitespace, the -w option. Nothing changes in
the repository.
- "Binary file — the content can't be displayed.": git doesn't show a text diff for it. Images are the exception: see "Image diff" below.
- "No content differences (e.g. only a mode change, a rename or an empty file).": the file changed, but not in its text.
- A submodule or a Git LFS pointer appears as a summary, instead of the text diff (see Submodules and Git LFS).
- Very large diffs are cut at around 2 MB of text; the end of the file doesn't appear. To see it whole, use the external diff tool.
- Very large blocks (hundreds of thousands of characters) appear without syntax highlighting, so the screen doesn't freeze.
- With strange characters in place of accented letters, the file is probably in another encoding: see Legacy encodings.
These are the two ways of drawing the diff. Unified interleaves the old and new lines in a single column; Split puts the old version on the left and the new one on the right, with the lines aligned.
- On the diff bar, on the right: Unified | Split. The tooltips say "Old and new interleaved" and "Old on the left, new on the right".
- Open a file's diff.
- Click Split. The removed lines are on the left and the added ones on the right, paired by position; the context appears on both sides.
- To go back, click Unified.
| Option | What it does | Default |
|---|---|---|
| Unified | One column, with old and new lines interleaved. | On |
| Split | Two columns: old on the left, new on the right. | Off |
- In split mode, each side has its own line numbers. To choose lines to stage or discard, click the numbers on the left (removed lines) or on the right (added lines).
- Narrow screens work better in unified mode, or in split mode with Wrap lines.
The choice is remembered between sessions and applies to all diffs.
By default the diff shows only the hunks: the changed blocks with a bit of context. The File view shows the whole file, with the changes highlighted where they are.
- On the diff bar, in the center: File | Diff. The tooltips: "Shows the whole file, with the changes highlighted" and "Shows only the changed hunks".
- The picker doesn't appear on a new file (which is already shown whole), on an image and in the Markdown preview.
- Open the diff and click File.
- Scroll normally, or use the Previous change / Next change arrows and the ruler on the right to go to each block.
- Click Diff to go back to the hunks.
| Option | What it does | Default |
|---|---|---|
| Diff | Only the hunks, with the chosen context lines. | On |
| File | The whole file. | Off |
In the File view, the diff is requested with a huge context (-U1000000), which brings the
whole file as a single hunk.
- In the File view, the hunk headers don't have the Stage hunk, Discard hunk and Stash buttons, because the whole file becomes a single hunk. To stage part of the file in this view, choose the lines (see Staging).
- The context lines control disappears in the File view: it would have no effect.
Context lines are the unchanged lines shown around each hunk. More context helps you understand where the change is; less context makes the diff short and splits nearby changes into smaller hunks, which you can stage or discard one by one.
- On the diff bar, on the right: − 3 +. The − ("Less context around the changes") decreases it, the + ("More context around the changes") increases it, and clicking the number goes back to git's default.
- Preferences › Navigation and appearance › Diff, blame and conflicts › Diff context lines.
- Open the diff in the Diff view.
- Click the + a few times: 3, 5, 8, 10… The diff is read again with the new context.
- Click the number to go back to 3.
| Option | What it does | Default |
|---|---|---|
| Accepted values | 1, 2, 3, 5, 8, 10, 15, 25 and 50 lines. The − stops at 1 and the + at 50. | 3 lines ("3 lines (git default)" in Preferences) |
| Clicking the number | Goes back to git's default. The tooltip reminds you: for the whole file, use File. | — |
git diff -U8 -- src/login.ts
With the default value (3), the app doesn't pass -U and git's own default applies.
- The control doesn't appear on a new file or in the File view.
- With more context, neighboring hunks can merge into one; with less, a large hunk can split. The stage and discard buttons act on the hunk as it appears on screen.
The choice applies to all diffs and is remembered. The same preference is in Preferences › Navigation and appearance (Navigation and appearance).
For IT
The Navigation and appearance page of Preferences can be hidden or locked by the company policy
(preferences.hidden / preferences.locked, id ergo-view). When locked, it shows "This page is
set by your company and is read-only."; the diff's own − 3 + control stays on the bar. See
Company policy.
Turns on git diff -w: the diff hides the differences that are only whitespace (indentation,
trailing spaces, tabs instead of spaces). It's for reading a change that came mixed with a
reindentation.
- On the diff bar, on the right: Ignore whitespace. The tooltip: "Hides differences that are only whitespace (git diff -w). While it's on, staging and discarding by hunk or by line are disabled: the diff without the whitespace can't be safely applied back."
- Open the diff of a reindented file.
- Click Ignore whitespace (the button becomes checked). The diff is read again without the spacing changes.
- Read what really changed.
- Click it again to turn it off before staging or discarding parts of the file.
| Option | What it does | Default |
|---|---|---|
| Ignore whitespace | Asks git for the diff with -w. | Off |
git diff -w -- src/login.ts
- While it's on, you can't stage or discard parts of the file: the hunk buttons are disabled ("Unavailable while "Ignore whitespace" is on: the diff without the whitespace doesn't match the real file and can't be safely applied back.") and the lines can't be chosen. Stage file for the whole file still works.
- The choice is remembered for the next diffs. If the hunk buttons are grayed out for no apparent reason, check whether Ignore whitespace is on.
- "No differences other than whitespace. Turn off "Ignore whitespace" to see the spacing changes.": the file only changed in whitespace.
- On a new file the button is disabled: "No effect on a new file: there's no previous version to compare with".
- Blame has its own Ignore whitespace (
git blame -w): see Blame.
The choice is remembered between sessions and applies to all diffs.
Long lines continue on the next line instead of requiring horizontal scrolling. Useful for text, Markdown, minified JSON and log lines.
- On the diff bar, on the right: Wrap lines ("Wrap long lines").
- Blame and the conflict editor have their own Wrap lines button (see Blame and The conflict editor); in the conflict editor, the three panes stay aligned.
- Preferences › Navigation and appearance › Diff, blame and conflicts › Wrap lines, with the In blame and In the conflict editor options.
- Open the diff of a file with long lines.
- Click Wrap lines. Each long line takes up several lines on screen, with a single number.
- Click it again to turn it off.
| Option | What it does | Default |
|---|---|---|
| Wrap lines (in the diff) | Wraps the long lines in the diff. | Off |
| In blame (Preferences) | The same in blame. | Off |
| In the conflict editor (Preferences) | The same in the three panes of the conflict editor. | Off |
Each screen's choice is remembered. The diff's is in the diff itself; the blame's and the conflict editor's also appear in Preferences › Navigation and appearance (Navigation and appearance).
In a large file, two tools take you straight to the changes.
- Arrows on the diff bar: Previous change and Next change. They jump to the start of the previous or next block of changes and wrap around at the end and the start of the file. They're disabled when the diff has no changes.
- Ruler on the right edge ("Changes in this file — click to jump there"): each mark is a block of changes, in green (additions), red (removals) or in both colors. Click the ruler to go to that point.
- Open the diff in the File view.
- Look at the ruler to see where the changes are.
- Click Next change to go from block to block, or click a mark on the ruler.
When part of a file's changes is already staged and part isn't, the file appears in both sections of the panel, and the diff gets a picker to switch between the two parts without going back to the list.
- On the diff bar, in the center: Unstaged | Staged. It only appears when the file is in both sections (and isn't a new file).
- Stage a hunk of
src/login.ts(see Staging). - In the diff, click Staged: only what goes into the commit appears.
- Click Unstaged: what was left out appears.
The File or Diff choice is kept when you switch sides.
In a Markdown file, the diff can show the formatted text (headings, lists, tables, code) instead of the source code. Good for reviewing documentation.
- On the diff bar, in the center, for
.md,.markdown,.mdown,.mkdand.mkdnfiles: Code | Preview. The tooltips: "Shows the Markdown as text, with the changes" and "Shows the formatted Markdown (the whole file, newest version)". - Preferences › Navigation and appearance › Diff, blame and conflicts › Markdown preview › Open Markdown files in preview.
- Open the diff of
README.md. - Click Preview. The diff switches to the whole-file view and shows the formatted Markdown ("Loading the whole file…" while it reads).
- Click Code to go back to the text diff.
| Option | What it does | Default |
|---|---|---|
| Code | The diff of the file's text. | On |
| Preview | The whole formatted file, in the newest version. | Off |
| Open Markdown files in preview (Preferences) | Every Markdown file opens directly in the preview. | Off |
- The preview shows the file as it ended up, without marking what changed. To see the changes, use Code.
- On a deleted file, the preview shows its last version: "This file was deleted: the preview shows its last version.".
- "The file is empty.": there's nothing to format.
- The preview is safe: nothing in the file becomes real HTML, links open in the browser and images aren't loaded.
- In the preview, the context, arrows, Unified/Split and Ignore whitespace controls disappear.
- The choice between Code and Preview applies to all Markdown files and is remembered.
- Preferences › Navigation and appearance (Navigation and appearance).
Images don't have a text diff, but Versora shows both versions for you to compare: side by side, with a divider that slides or one over the other with transparency. It works for PNG, JPG/JPEG, GIF, WebP, BMP, ICO and SVG.
- Open an image's diff like any other file's. The image bar has Side by side | Swipe | Onion skin | Pixel.
- SVG is image and text at the same time: the diff bar gets Image | Code ("Compares the drawing: before and after" and "Compares the SVG code, line by line"). The SVG starts as an image; in Code it has a normal text diff, with staging by hunk and by line.
| Mode | What it shows |
|---|---|
| Side by side | "Before on the left, after on the right". |
| Swipe | "One image over the other, with a divider you drag". The Divider control changes the position: before on its left, after on its right. |
| Onion skin | "One image over the other, with adjustable transparency". The control goes from Before to After and changes the opacity of the new version. |
| Pixel | Pixel-by-pixel comparison (next section). |
Above each version appear the Before or After label, the dimensions (for example, 512 × 512 px), the file size and, on the new version, how much it grew or shrank. If the dimensions changed, they're highlighted ("The dimensions changed"). Both versions are drawn at the same scale, so the size difference is visible. Small images (icons) are enlarged, without smoothing, so you can see what changed.
- Click the
assets/logo.pngfile in the changes panel. - Start with Side by side to see both versions.
- Switch to Swipe and drag the Divider control to reveal one version over the other.
- In Onion skin, move the control between Before and After to see the transition.
| Option | What it does | Default |
|---|---|---|
| Mode | Side by side, Swipe, Onion skin or Pixel. It's remembered for the next images. | Side by side |
| Divider / opacity | Position of the divider (Swipe) or opacity of the new version (Onion skin). | In the middle |
- "New image: it didn't exist before." / "Deleted image: it no longer exists.": only one side exists, and the screen shows only that one.
- "Both versions are identical (same bytes).": the file appears as changed, but the content is the same (for example, only the file mode changed).
- "Image too large to preview (15 MB; the limit is 12 MB).": images above 12 MB aren't shown.
- "This file is in Git LFS: the repository only stores a pointer, and the preview doesn't download the content." See Git LFS.
- "Couldn't decode the image (corrupted file or unsupported format)."
- When one of the versions can't be shown, only Side by side is available ("Available when both versions can be displayed").
- An image can only be staged as a whole file.
Pixel mode compares the two versions of an image pixel by pixel and paints each pixel that changed in a highlight color, over the faded image. It finds the difference the eye can't see: an icon with one pixel swapped, a slightly different color, a shifted crop.
- In an image's diff: Pixel ("Compares pixel by pixel and highlights what changed, with zoom and toggling"). It's only available when both versions can be displayed.
- Open an image's diff and click Pixel. "Comparing pixel by pixel…" appears and then the result, for example "1,234 different pixels (0.5%)" and "Changed area: x 10, y 20, 30 × 40 px".
- Click Go to the change: the zoom increases and the screen scrolls to the changed area.
- Hover over the image to see the pixel's position and colors in both versions, for example "x 12, y 30 · before 255, 0, 0, 255 · after 250, 0, 0, 255" (red, green, blue and transparency).
- If the image only changed because of compression or color rounding, increase the Tolerance until the irrelevant differences disappear.
- Switch to Toggle to see one version and the other in the same place.
| Option | What it does | Default |
|---|---|---|
| Difference | "Different pixels highlighted over the faded image". | On |
| Toggle | "Shows one version and the other in the same place, blinking or by hand". With Before and After you choose the version; Blink / Stop turns the automatic switching on and off. | Blinking |
| Tolerance | "Per-channel difference (0 to 255) below which a pixel counts as equal. 0 = exact pixel." The control goes from 0 to 64. Only in Difference mode. | 0 |
| Zoom | Fit (fits the screen) or 1×, 2×, 4×, 8×, 16× and 32×, with sharp pixels. | Fit |
- "The images are identical pixel by pixel (the file only changed in metadata or compression).": the file changed, but the image didn't.
- Different dimensions: the comparison uses the area of both starting from the top left corner; what only exists in one of them counts as different.
- "Image too large for the pixel-by-pixel comparison. Use Side by side, Swipe or Onion skin.": images with more than 25 million pixels (for example, above 5000 × 5000) can't use Pixel mode.
- "Couldn't read the pixels of the images."
- The highlight color follows the app theme.
Some diff buttons lead to features explained on other pages:
- Edit file (on the left of the bar, only on local changes): "Open the file in the system's default program". If the file no longer exists, "File not found: …" appears.
- Encoding (on the right of the bar): shows how the file was read (UTF-8, Windows-1252, UTF-16…) and lets you choose another one. See Legacy encodings.
- Owners (on the header): the file's owner according to CODEOWNERS. See Checks.
- Blame and History: see Blame and File history.
- Open in external diff tool icon (on the header): see git mergetool and git difftool.
- Line history (on the bar of the chosen lines): see Line history.
- In the diff of a commit on the current branch, each hunk has a button to move it to another commit: see Moving between commits.