Conflicts
The conflict editor
18 min read
The conflict editor opens a conflicted file in Versora's central area, in place of the diff. It has three panes:
- at the top left, the Current version (
ours); - at the top right, the Incoming version (
theirs); - at the bottom, the Result: exactly what will be saved to the file, editable like a text editor.
Each conflicting block has a checkbox to keep the whole block from one side, and each line has its own, to build the result line by line. What you check appears right away in the result, with the color of the side it came from. When all the file's conflicts have a decision, Save and mark resolved writes the file and stages it.
What "current" and "incoming" mean depends on the operation (in a rebase they're reversed). The table is in Conflicts › Current and incoming.
- Changes panel (the graph's WIP row) › Conflicted section: click the file.
- Menu of the conflicted file (right-click it): Open in the conflict editor.
- When an operation stops at a conflict, select the WIP row in the graph.
- In the Conflicted section, click the file. While the versions are read, "Loading the conflicting versions…" appears.
- The editor opens at the file's first conflict, or at the conflict where you left off, if you had already opened this file before.
- If you open a diff or select another commit, the editor steps aside, but the choices and edits are kept. When you click the file again, you continue from where you left off.
- If the conflicting versions changed in the meantime (the merge was redone, the file was started over outside the app), the old choices no longer apply and the editor starts from scratch.
- If the file stopped being conflicted another way (resolved in the terminal, marked as resolved, operation aborted), the editor closes on its own.
- A Ctrl+Z (or Ctrl+Shift+Z) that touches the file changes the content under the editor: the saved choices for that file no longer apply. If the editor was open on it and the file went back to conflict, the editor reads the versions again and reopens; if it didn't, the editor closes.
- Closing the repository tab discards what wasn't saved.
To open the file, the app reads the three versions git kept in the index during the conflict (base,
current and incoming) and redoes their combination with git merge-file, in the common marker
style (your configuration's merge.conflictStyle, such as diff3, is ignored here), to show the
leanest blocks. Nothing is written just by opening the editor.
git ls-files -u -- src/pedido.ts # the conflicting versions (stages 1, 2 and 3)
git merge-file -p current base incoming # the combination, done on temporary files
- "The file is no longer in conflict: src/pedido.ts": the conflict was resolved another way. Refresh the screen (F5).
- "Git couldn't compare the versions of the file.": the combination failed. Use the external merge tool or resolve it in the terminal.
| Part | What it shows or does |
|---|---|
| Header | Folder and file name and the operation ("merge conflict", "rebase conflict", "cherry-pick conflict", "revert conflict" or "conflict (applied stash or patch)"). The Merge tool, Start over, Cancel and Save and mark resolved buttons. |
| Bar, on the left | Accept all current and Accept all incoming. |
| Bar, in the middle | The Previous conflict and Next conflict arrows, the counter ("conflict 2 of 5") and the progress ("3 undecided" or "all resolved"). On a file without overlapping blocks, "no content conflicts". |
| Bar, on the right | Wrap lines, the information chips and Open file. |
| Current pane and Incoming pane | The side's tag, its real name (branch or commit), the commit's short SHA and subject, and a line with that side's role in the operation. Lines that are the same on both sides appear as context; each conflict has a "Conflict N" header with the line count and the state. |
| Divider | Between the top panes and the result. Drag it to change the height ("Drag to resize"). The position is saved. |
| Result | The text that will be saved, with syntax highlighting and the origin color of each line. It shows "2 of 5 conflicts resolved — what will be saved to the file" and the legend: current, incoming, edited by hand, undecided. |
| Strips next to the scrollbar | One mark per conflict, colored by its state. See the "Navigate between conflicts" section below. |
The two top panes scroll together, line by line. The result has a different number of lines (marker blocks, chosen blocks), and the app converts the position from one to the other: scrolling any pane takes the others to the same point in the file.
| Chip | When it appears | What it means |
|---|---|---|
| added on both sides | The file has no common earlier version | "The file was created separately on both sides; there's no common earlier version" |
windows-1252 | The file isn't UTF-8 | "The file isn't UTF-8; it's read and saved in this encoding" |
| LF, CRLF or CRLF + LF | Always | The file's line ending, kept when saving. With CRLF + LF (mixed), each line keeps its own and new lines use the most common line ending. |
The app also keeps the file's BOM, if the versions had one.
This is the main way to resolve: you say, conflict by conflict, what stays from each side.
- Take the editor to the conflict (arrows, Alt+↓ or click the block).
- To keep a whole block, check the box on the "Conflict N" header on the side you want ("Use the whole block from the current version").
- To keep both, check both boxes. The side checked last goes in last in the result: to put the incoming block before the current one, check the incoming one first.
- To choose lines, check the box next to each line's number ("Include this line in the result"). The lines go into the result in the order you check them, not in the file's order. Clicking again removes the line ("Remove this line from the result").
- Check the result below: the chosen block appears with the color of the side it came from.
| Element | States | What it does |
|---|---|---|
| Box on the conflict header | Checked, partial (some lines) or unchecked | Checks or unchecks all of that side's lines in the block. |
| Box on the header of a side without lines | Checked or unchecked | "Use the current version here (it has no lines in this block, so the block is removed)". The pane shows "— no lines on this side —". |
| Box on each line | Checked or unchecked | Includes the line in the result or removes it. |
| Conflict state (badge on the header) | undecided, resolved or edited by hand | With no box checked, the conflict becomes "undecided" again and reappears in the result as git's marker block. |
- Replace manual edit: if you had already edited the block by hand in the result, checking a box replaces what you typed. The app asks first: "Conflict 2 was edited by hand in the result. This choice replaces what you typed in that block." Confirm with Replace.
Resolves all the conflicts of the open file at once with a single side. Only the conflicting blocks change: what git already combined without a conflict stays as it is.
- Editor bar: Accept all current or Accept all incoming. The tooltip shows the side's real name, for example "Resolves every conflict with the current version — main (the branch you're on)".
- Click Accept all current or Accept all incoming.
- If any conflict had a manual edit, confirm Replace.
- Check the result and click Save and mark resolved.
Tip
To keep the whole file from one side, without opening the editor, use the file menu (Use the current version…). For several files, use Resolve several….
The Result pane is a real text field: cursor, selection, paste and typing Ctrl+Z work as in any editor. Use it to adjust what the boxes built or to write a solution that isn't on either side.
- Click the result and edit.
- A conflict also counts as resolved when you delete its markers by hand (the
<<<<<<<,=======and>>>>>>>lines). The conflict's badge becomes edited by hand. - If a marker is still left in an edited block, the conflict stays undecided.
| Color in the legend | Meaning |
|---|---|
| current | Line that came from the current version |
| incoming | Line that came from the incoming version |
| edited by hand | Line of a block you changed in the result |
| undecided | Marker block of a conflict that is still pending |
- "The file on disk no longer has conflict markers: it was already resolved (before being reopened, or in another program).": the file on disk already has a resolution, the one you made before using Reopen (see "Reopen an already resolved file" below) or the one from an external editor. The Use the disk content as the result button brings that content into the result, for you to check, adjust and save.
- "The changes on both sides don't overlap in this file: the result below already combines them. Review it and save.": git marked the file as conflicted, but there's no overlapping block. Just check it and click Save and mark resolved.
- Shortcuts: Alt+↓ (Next conflict) and Alt+↑ (Previous conflict), with the focus on the editor. After the last one, it goes back to the first.
- Bar: the arrows next to the counter.
- Click any line or header of a conflict to make it the current one.
- Strips next to the scrollbar: click a mark to take the three panes to that conflict.
Next to the scrollbar of the top panes and of the result there's a narrow strip with one mark per conflict, at a height proportional to its place in the file. With them you see at a glance where the remaining conflicts are in a long file.
| Mark color | State (mark tooltip) |
|---|---|
| Yellow | "Conflict 3: pending" |
| Green | "Conflict 3: resolved" |
| Blue | "Conflict 3: edited by hand" |
The current conflict gets an outline.
The next and previous keys can be changed in the shortcut map ("Next conflict" and "Previous conflict", in the "In the conflict editor" context). See Shortcuts.
The bar's Wrap lines button ("Wrap long lines in the three panes of the conflict editor") makes long lines continue on the next line instead of requiring horizontal scrolling. The three panes stay aligned: each line takes the height of the tallest one among the sides.
- The choice is saved. It can also be turned on in Preferences › Navigation and appearance › Diff, blame and conflicts › Wrap lines › In the conflict editor. Default: off.
- The code font and size of the three panes follow Preferences › Navigation and appearance › Fonts › Code font. See Zoom and fonts.
Writes the result to the file and stages it: for git, that file's conflict is resolved.
- Editor header: Save and mark resolved ("Saves the file and stages it for the commit (git add)").
- Decide all of the file's conflicts. While there's an undecided conflict, the button is disabled, with the tooltip "2 conflicts still undecided".
- Click Save and mark resolved.
- The notice "pedido.ts resolved and staged for the commit" confirms it. The file leaves the Conflicted section and appears in Staged files.
- Open the next conflicted file or, if there are no more, click Continue on the operation bar.
The app writes the file keeping the encoding, the BOM and the line endings of the conflicting versions, and then stages it:
git add -- src/pedido.ts
Ctrl+Z undoes the resolution ("Undo: Resolve conflict in pedido.ts (Ctrl+Z)"): the file goes back to the Conflicted section, with the conflicting versions in the stage and, on disk, the content it had before you saved. Ctrl+Shift+Z redoes it. This applies while the operation stays stopped: when it ends, Ctrl+Z undoes the whole operation (see Operations stopped halfway).
To redo a file's resolution later, without undoing what came after, use Reopen in the Resolved section of the changes panel (see "Reopen an already resolved file" below). To give up on the whole operation, use Abort on the operation bar.
- Conflict marker in the result: "Line 42 of the result looks like a leftover conflict marker ("<<<<<<<" or ">>>>>>>"). Save anyway?". Go back and delete the marker, or confirm Save anyway if the line is real content. Lines that look like markers and already existed on one of the sides don't trigger the warning.
- "The file is in Windows-1252 (Latin-1) and the character "…" doesn't exist in that encoding. Remove it or convert the file to UTF-8 outside the app.": you typed a character the file's encoding can't represent.
- "Couldn't write …": the file is locked by another program or there's no write permission.
Closes the editor without saving anything.
- Header: Cancel ("Close without saving (Esc)").
- Shortcut: Esc ("Cancel editing the result"). This key is fixed.
- If there are choices or edits, the app asks: Cancel resolution, "Close the editor and discard the choices and edits made in "src/pedido.ts"? Nothing has been saved to the file.". Confirm with Discard and close.
Puts the file back in its original conflicted state, with git's markers, and reopens the editor from scratch. It discards the choices made in the editor and also whatever was already written to the file by another program (for example, a half-done resolution in an external editor).
- Editor header: Start over ("Puts the file back in its original conflicted state (git checkout -m)").
- Click Start over.
- Confirm Start over in the Start resolution over dialog: "Put "src/pedido.ts" back in its original conflicted state? The choices made in the editor and any change already saved to this file will be discarded; the file will have Git's conflict markers again."
- The notice "pedido.ts is back in its original conflicted state" confirms it, and the editor reopens.
git checkout -m -- src/pedido.ts
Ctrl+Z ("Undo: Reset pedido.ts to the original conflict (Ctrl+Z)") puts the file back as it was before starting over, on disk and in the stage. It's the way to recover a resolution that was saved in the file and that Start over discarded.
- "This isn't a content conflict (one of the sides doesn't have the file), so there are no markers to recreate.": Start over only applies to content conflicts.
- Start over also works on a file you reopened with Reopen: it replaces the resolution that was on disk with git's markers.
After Save and mark resolved, Use the … version…, Resolve several… or a stage, the file leaves the Conflicted section and the editor no longer opens on it. While the operation isn't finished, git still keeps that file's conflicting versions. The Resolved (n) section of the changes panel lists these files, and each one's Reopen button puts the file back in conflict, for you to redo the resolution.
- Changes panel (the graph's WIP row) › Resolved (3) section, right below Conflicted. The section's tooltip says: "Files that were in conflict in this operation and are already resolved. Until the commit that finishes it, each one can go back to the conflict editor."
- On each file of the section: the Reopen button ("Puts the file back in conflict and opens the conflict editor, with your resolution still on disk (Start over goes back to Git's markers). Ctrl+Z undoes it.").
The section appears with a stopped merge, rebase, cherry-pick or revert, or with conflicted files, and only when there are files to reopen. Click the title to collapse or expand the list.
- Select the WIP row in the graph and expand the Resolved section.
- Click Reopen on the file, for example
src/pedido.ts. The indicator shows "Reopening the conflict…". - The file goes back to the Conflicted section and the conflict editor opens on it, with the current and incoming versions and the notice "The file on disk no longer has conflict markers: it was already resolved (before being reopened, or in another program)."
- Choose how to go on:
- Use the disk content as the result brings back the resolution you had made, to adjust it;
- choosing blocks and lines builds a new resolution;
- Start over replaces the file on disk with git's conflict markers.
- Click Save and mark resolved.
- The ones that were conflicted in this operation and were resolved in a way in which git keeps the
conflicting versions: the conflict editor, Use the … version…, Resolve several…, a stage
or a
git addfrom the terminal. - In a rebase, only those of the current step: a resolution from an earlier commit of the rebase isn't part of this conflict and doesn't appear.
- After the commit that finishes the operation, the section disappears.
git keeps the conflicting versions of each resolved file (the index's resolve-undo extension). The app lists those files and, when reopening, puts the conflict back in the stage without touching the file on disk:
git ls-files --resolve-undo -z # files that can still go back to conflict
git update-index --unresolve -- src/pedido.ts # the conflict goes back to the stage (stages 1, 2 and 3)
Ctrl+Z ("Undo: Reopening of pedido.ts (Ctrl+Z)") puts the file back to resolved, as it was before reopening.
- "src/pedido.ts can't be reopened: git no longer keeps its conflicting versions (the operation was finished, or the file was resolved in a way that doesn't keep them).": the list was out of date, or the file was resolved by a command that doesn't record the versions. Refresh the screen (F5). Without the saved versions, the way to redo the resolution is to edit the file by hand and stage it again, or use Abort and start the operation over.
- Reopen doesn't erase your resolution: it stays on disk until you save another one or use Start over.
When the file can't be combined line by line, the editor shows a choice screen: the type of conflict, an explanation with the real names of the sides, a card for each version ("The file exists in this version (12.4 KB).", "The file doesn't exist in this version.") and the possible buttons. When only one side has the file and it's text, the screen also shows the content of that version ("Content in the current version — main"). To close it, use the X ("Close (Esc)") or Esc.
| Type (screen title) | When it happens | Buttons |
|---|---|---|
| Binary file changed on both sides | The content is binary, or .gitattributes tells merge to treat the file as binary (-merge or merge=binary) | Use the current version — main, Use the incoming version — feature/login |
| File too large for the conflict editor | One of the versions is over 2 MB | The same two buttons. Or resolve it in an external editor and mark the file as resolved. |
| Modified on one side, deleted on the other | Modified in the current version and deleted in the incoming one | Keep the file (current version — main), Delete the file (as in feature/login) |
| Deleted on one side, modified on the other | Deleted in the current version and modified in the incoming one | Keep the file (incoming version — feature/login), Delete the file (as in main) |
| The file only exists in the current version / The file only exists in the incoming version | It's usually the same file renamed or moved in different ways on the two sides | Keep this file, Delete this file |
| Deleted on both sides | The path was deleted or renamed on both sides (the new names appear as other conflicted files) | Confirm deletion |
| Submodule conflict | The conflict is in a submodule's commit | None: "The app can't resolve submodule conflicts yet. Resolve it in the terminal (for example, choosing the submodule commit and running git add) and then continue the operation here." |
git checkout --ours -- docs/manual.md # or --theirs: keeps that side's version
git add -- docs/manual.md
git rm -f -q -- docs/manual.md # "Delete the file": resolves by deleting
Ctrl+Z puts the file back in conflict: "Resolve conflict in manual.md" when you kept a version, "Delete manual.md" when you deleted it (the file comes back to disk as it was). It applies while the operation stays stopped.
- Before deleting, the app confirms: Delete the file, "Resolve the conflict by deleting "docs/manual.md"? The file is removed from disk and the deletion is staged for the commit.".
- "docs/manual.md deleted; conflict resolved" confirms the deletion.
- "Submodule conflicts can't be resolved in the app; use the terminal.": appears if you try Use the … version… on a submodule.
Resolves the whole file with one side, without opening the editor. It's for files where you already know which version stays (a generated file, a lockfile).
- Menu of the conflicted file (right-click in the Conflicted section): Use the current version… or Use the incoming version….
- Right-click the file and choose the side.
- The dialog shows the side's real name and what is lost, for example: Use the current version, "Resolve all of "package-lock.json" with the current version — main (the branch you're on). In this file, what came from feature/login will be discarded."
- Confirm Use the current version. The notice "package-lock.json resolved with the current version (main)" confirms it.
git checkout --ours -- package-lock.json # --theirs for the incoming version
git add -- package-lock.json
Ctrl+Z ("Undo: Resolve conflict in package-lock.json (Ctrl+Z)") puts the file back in conflict, as it was before. To redo it later, use Reopen in the Resolved section (above).
- If the chosen side doesn't have the file, using that version means deleting it. The dialog becomes Use the incoming version: delete the file, and the button, Delete file.
- If the other side had deleted the file, the dialog warns: "The file will be kept, even though it was deleted in feature/login."
- If you had already made choices in the editor for that file: "The choices already made in the editor for this file will also be discarded."
- "The file doesn't exist in that version (it was deleted there). Use the option to delete the file.": appears if the list changed between opening the menu and confirming.
The header's Merge tool button ("Open this file in the external merge tool") and the Open in
merge tool item in the file menu open the conflict in the program configured in Preferences ›
Operations › Diff and merge tools. When you finish the merge there, the file is marked as
resolved. It only opens content conflicts. The configuration and using Versora as git mergetool
are in External merge and diff tools.