Repository navigation
How Conflict Resolution Works
When a merge, rebase, cherry-pick or revert stops on conflicts, Nibtree shows a banner, a Conflicts dialog and inline editor actions, and lets you continue or abort. The merge tool has its own page, How the merge tool works. The user side is in Resolving Conflicts.
Resolving conflicts is the reason this app exists, and different conflicts need different tools: whole files (yours or theirs, the only option for binary and "deleted on one side" conflicts), inline markers in the editor, and the merge tool for real conflicts in a file.
Git stays in charge: we read its state and run its own --continue, --abort and --skip, so the result matches the terminal.
opstate::read in src-tauri/src/git/opstate.rs looks at git2's repo.state() and returns an OpState: the kind (merge, rebase, cherryPick, revert, other or none), a short description such as "Merging feature into main", and labels for the two sides. It is part of every RepoStatus, so the banner updates with each status refresh.
Commands that may stop on conflicts return an OpOutcome. commands::outcome treats a failed git command that left conflicts behind as a normal result with conflicts: true, not an error. repoStore.runOp then makes that repository active and opens the Conflicts dialog.
stateDiagram-v2
[*] --> Clean
Clean --> Conflicted: merge, rebase, cherry-pick or revert stops
Conflicted --> Conflicted: accept a side, merge tool, Mark as Resolved
Conflicted --> AllResolved: last conflicted file staged
AllResolved --> Clean: Continue (git subcommand --continue)
AllResolved --> Conflicted: Continue, the next rebase commit conflicts
Conflicted --> Clean: Abort, after confirmation
AllResolved --> Clean: Abort, after confirmation
Conflicted --> Conflicted: Skip Commit (rebase only)
OpBanner.svelte shows the description and conflicted file count, with Resolve Conflicts, Continue (once nothing is left), Skip Commit (rebase only) and Abort. Abort asks first. For an other state, such as git am or a bisect, it offers neither Continue nor Abort. The banner acts on the active repository.
The three actions live in views/git/operationActions.ts (continueOperation, abortOperation, skipRebaseCommit), shared by the banner and the Git menu. menuState.ts shows the menu items only while they apply and names them after the operation, such as "Continue Merge". After --continue, --abort or --skip, the backend calls cleanup_rebase_files, which removes the message files of an interactive rebase once no rebase is in progress.
ConflictsDialog.svelte calls listConflicts, which reads the conflict entries of the index in conflicts::list. Each file gets a FileConflictKind from which stages exist: bothModified, bothAdded, deletedByUs or deletedByThem, plus a binary flag. It reloads on every status change.
sequenceDiagram
participant Dlg as ConflictsDialog.svelte
participant Store as repoStore.run
participant Cmd as commands/merge.rs
participant Git as git CLI
Dlg->>Store: run("Accept yours", acceptSide(paths, ours))
Store->>Cmd: accept_side
Cmd->>Cmd: read index conflicts, split paths
Cmd->>Git: checkout --ours, then add (side has the file)
Cmd->>Git: rm -q (side deleted the file)
Store->>Store: refreshRepo, dialog reloads
Dlg->>Store: runOp("Continue", continueOperation)
Store->>Cmd: continue_operation
Cmd->>Git: merge, rebase, cherry-pick or revert --continue
operation_subcommand picks the git subcommand from the OpKind. The git runner sets GIT_EDITOR=true, so --continue accepts the prepared message instead of waiting for an editor. Double click or Enter on a text file opens the merge tool (repoStore.openMerge).
src/lib/editor/conflictMarkers.ts is pure. findConflicts scans for complete <<<<<<<, ======= and >>>>>>> regions, understands the ||||||| base section of the diff3 and zdiff3 styles, keeps the branch labels and skips incomplete regions. resolveEdit and resolveAllEdits build the edits for a choice.
src/lib/editor/conflictDecorations.ts keeps the regions in conflictField, a StateField recomputed when the document changes. EditorView.decorations.compute turns it into colored lines, "(Current Change)" and "(Incoming Change)" labels, and a block widget with the action links above each region. barWidth caps the row at the visible width so it wraps, keeping the "Conflict 1 of 2" counter in view. Clicking a link dispatches the edit, so Cmd+Z undoes it.
In FileView.svelte, a file with markers or one git lists as conflicted gets a tinted strip under the path bar (toolbar "Conflict actions") with Accept All Current and Accept All Incoming, Resolve in Merge Tool (asking first about unsaved edits, since the merge tool starts from git's versions), and Mark as Resolved once no markers are left. Mark as Resolved calls saveResolution, which writes the file and runs git add.
| File | What it does |
|---|---|
src-tauri/src/git/opstate.rs |
OpKind, OpState, side labels |
src-tauri/src/git/conflicts.rs |
list, classify, loading the three stages |
src-tauri/src/commands/merge.rs |
list_conflicts, accept_side, save_resolution, continue_operation, abort_operation, skip_rebase_commit
|
src-tauri/src/commands/mod.rs |
outcome and run_op
|
src/lib/views/OpBanner.svelte |
The banner and its buttons |
src/lib/views/git/operationActions.ts |
Continue, Abort and Skip Commit, shared with the Git menu |
src/lib/merge/ConflictsDialog.svelte |
The file list, Accept Yours or Theirs, Merge, and Continue once all are resolved |
src/lib/editor/conflictMarkers.ts |
Pure marker parser and resolution edits |
src/lib/editor/conflictDecorations.ts |
CodeMirror field, decorations, action widgets, barWidth
|
src/lib/views/files/FileView.svelte |
The conflict strip: Accept All, Resolve in Merge Tool, Mark as Resolved |
src/lib/views/files/fileMenus.ts, fileSave.svelte.ts
|
Resolve in Merge Tool asks about unsaved edits; Mark as Resolved writes and stages |
Let git run the operation. We never reimplement continue or abort. Git's own commands keep hooks, rerere and the sequencer state correct.
Name the sides for what they are. During a rebase, HEAD is the branch you rebase onto, so "ours" is the upstream and "theirs" is your replayed commit. opstate::read labels them "Upstream" and "Your commit" instead of a confusing "Yours" and "Theirs".
Conflicts are an outcome, not an error. A merge that stops on conflicts did its job, so outcome reports conflicts: true and the UI opens the dialog, not an error toast.
Block widgets from a StateField. CodeMirror does not allow block decorations from a ViewPlugin, so the action bars come from conflictField through a decorations facet.
Mark as Resolved is explicit. Cmd+S only saves, so you can stop halfway. Staging waits until you say the file is done.
Escape closed two dialogs at once.
- The issue: pressing Escape on a confirmation shown over the Conflicts dialog closed both.
- Why it happened: its window Escape handler also got the key meant for the confirmation.
-
The fix and why we chose it: its
onKeydownreturns early whenevent.defaultPreventedordialogs.activeis set. The same check is now a project rule for every window-level key handler.
The conflict counter was hidden.
- The issue: in a file with several conflicts, the "Conflict 1 of 2" counter at the end of the inline actions row never showed at normal window sizes.
- Why it happened: the actions row is a block inside the editor content, which is as wide as its longest line, so the row never wrapped and the counter sat past the visible edge.
-
The fix and why we chose it: the ViewPlugin
barWidthinconflictDecorations.tsmeasures the visible editor width on every geometry change and sets--cm-conflict-bar-width. The row is capped at that width and wraps, so the counter moves to a second line instead of disappearing.
-
src-tauri/src/git/tests.rs:merge_conflicts_are_listed_with_kinds_and_binary_flags,merge_labels_fall_back_to_merge_head_branch_without_merge_msg,rebase_conflict_labels_upstream_as_ours,cherry_pick_and_revert_conflicts_are_detected, and the demo script tests. -
src-tauri/src/commands/tests.rs:accept_side_*,save_resolution_writes_content_and_stages_it,continue_operation_completes_merge,abort_operation_restores_pre_merge_state, the rebase, cherry-pick and revert flows, andskip_rebase_commit_drops_the_conflicting_commit. -
src/lib/editor/conflictMarkers.test.ts: labels, diff3, look-alike markers and every resolution choice.
scripts/make-conflict-repo.sh builds every conflict type, and the Rust tests assert its exact output, so update src-tauri/src/git/tests.rs when you change it. See Testing.
- Update this page when an operation kind, a side label, the banner or Git menu actions or the marker parser change.
- Update Resolving Conflicts for visible changes.
- Retake
operation-banner.png,conflicts-dialog.png,inline-conflict-actions.pngandeditor-conflict-toolbar.png. See Docs and Screenshots.
These pages are generated from docs/wiki. To correct something, open a pull request against the source file; edits made here are overwritten.
Using Nibtree
- Getting Started
- Welcome Screen
- Workspaces
- Files Panel
- File Operations
- File Icons
- Rounded Panels
- Editor and Tabs
- Pin Reorder and Wrap Tabs
- Single Tab Title
- Split Editor
- New File and Unsaved Changes
- Unload Hidden Tabs
- Editing Code
- Code Appearance
- Markdown Editor
- Image and PDF Preview
- Search Everywhere
- Recent Files
- Navigation Bar
- Find and Replace
- Changes and Commits
- Sign In Prompts
- Commit Box Layout
- Repository Actions
- Commit Options
- Ignoring Files
- Diffs
- Inline Diffs
- Staging View
- Revert a Change
- Resolving Conflicts
- Merge Tool
- Blame
- History and Log
- Merge Commits
- Branches and Tags
- Branches Popup
- Remotes
- Stashes
- Shelf
- Git Menu
- Git Dialogs
- Interactive Rebase
- Worktrees
- AI Agents
- AI Tasks
- AI Usage
- Keep Computer Awake
- Submodules
- Git LFS
- GitHub
- Git Console
- Terminal
- Terminal Features
- Scripts
- Navigation
- Menus
- Settings
- Settings Search
- Color Themes
- Settings Terminal and Automation
- Settings Files
- Updates
- Status Bar and Help
- Notifications
- Memory Use
- Clear Cache
- MCP and CLI
- Git Mergetool
- Keyboard Shortcuts
- Keyboard Shortcuts Editor
- Troubleshooting
- Troubleshooting Git
Developers
- Developer Guide
- Architecture
- Project Layout
- Backend
- How Folder Watching Works
- Folder Watching Bugs We Fixed
- How Workspace Files Work
- How the Preview Scheme Works
- Backend Services
- How Terminal Features Work
- Terminal Bugs We Fixed
- Frontend
- How the Rich Markdown Editor Works
- Rich Markdown Bugs We Fixed
- Git Menu Links
- Menu Keys and Routing
- Frontend Modules
- Blame Bugs We Fixed
- Project Color And Title Bar
- One Diff View
- Diff Bugs We Fixed
- Merge Tool Layouts
- Merge Tool Bugs We Fixed
- Color Theme Bugs We Fixed
- How the Connected Diff Works
- Rounded Panels Bugs We Fixed
- Update Bugs We Fixed
- Status Bar Bugs We Fixed
- MCP and CLI Bugs We Fixed
- Repository Actions Bugs We Fixed
- How the Changes Tab Works
- CodeMirror Patterns
- How the Cursor Works
- How Editor Features Work
- How the Path Bar Works
- Commands and Events
- Settings Reference
- Commands Workspace and Changes
- Commands Branches and Remotes
- Commands History and Extras
- Commands App and Tools
- Testing
- Test Suites
- Debugging
- Debugging with MCP
- Measuring Setting Memory
- How Terminal Memory Is Measured
- How Markdown Diagrams Work
- Releases and CI
- Publishing the Wiki
- Versioning and Changelog
- Browser Version Packages
- Browser Release Checks
- Docker Image
- Platforms and Signing
- Windows Support
- Windows Bugs We Fixed
- Windows MCP and CLI
- Docs and Screenshots
- UI Library
- UI Library MCP
- UI Library Bugs
- UI Library Migration
- Contributing
How features work
- Welcome screen
- Workspaces and folders
- Files panel
- File operations
- File icons
- Editor and tabs
- Pin, reorder and wrap tabs
- Single tab title
- Split editor
- New File and unsaved changes
- Unload hidden tabs
- Editing code
- Code appearance
- Markdown editor
- Image and PDF preview
- Search Everywhere
- Recent Files
- Navigation Bar
- Find and replace
- Changes and commits
- Sign-in prompts
- Commit box layout
- Repository actions
- Commit options
- Ignoring files
- Diffs
- Inline diffs
- Staging view
- Revert a change
- Resolving conflicts
- Merge tool
- Blame
- History and log
- Merge commits
- Commit tabs
- Branches and tags
- Branches popup
- Remotes
- Stashes
- Shelf
- Git menu
- Git dialogs
- Interactive rebase
- Worktrees
- AI agents
- AI usage
- Keep computer awake
- AI tasks
- Submodules
- Git LFS
- GitHub account
- Git Console
- Back and Forward
- Integrated terminal
- Scripts tool window
- Menu bar
- Settings
- Search in Settings
- Color themes
- Rounded panels
- Updates and release channels
- Status bar and help links
- Notifications
- Memory readout and memory log
- Clear Cache
- MCP server and command line tool
- git mergetool mode