Skip to content
Versora

Manual

Conflicts

Predicting conflicts before an operation

9 min read

On this page

Finding a conflict only after starting the operation means stopping halfway, with the operation in progress bar and files with markers. Versora tries to warn you beforehand: it simulates the operation in memory, without touching the working directory, the stage or the branches, and says in which files it will conflict. You decide whether to go ahead, prepare the ground first or give up.

This is the main page about conflict prediction. It explains:

How the prediction works

The predictions on this page use the same technique: git merge-tree, which calculates the result of a combination without a working directory. The objects the simulation would create go into a temporary object database, not into your repository. No file, branch or stage changes.

These apply to all of them:

  • It compares commits. Uncommitted changes in the working directory aren't taken into account.
  • It never blocks the operation. If the simulation before a merge, rebase, cherry-pick or revert fails or takes longer than 15 seconds, the operation goes ahead as usual, without a warning.
  • It needs a recent git: 2.38 for the prediction between branches and 2.40 for the cherry-pick and revert preview. With an older git, the prediction is unavailable and the operation goes ahead directly. See Git version.

Prediction between branches

The prediction between branches simulates merging one branch into another. It appears in three places: the badge on branches, the warning before a merge or rebase and the note in the merge request form. All three are in Preferences › Checks › Conflict prediction, because they're part of the app's checks.

The badge on branches

Where to find it

  • Left panel, LOCAL section: the conflict icon next to the branch that is expected to conflict.
  • Graph: the same icon, smaller, on the local branch label.
  • Palette (Ctrl+P): "Refresh conflict prediction" (detail: "Compares local branches with the target").

Hover over the icon to see the explanation and the list of files: "Conflict predicted: merging feature/login into main is expected to conflict in 2 files:" followed by the files.

How the badge is calculated

  • The prediction compares each local branch with the prediction target (below).
  • It runs on its own when you switch tabs or when the local or remote branches change (commit, fetch, checkout…), after a short pause, so several changes in a row become a single calculation.
  • The result for each pair of commits is saved: after a fetch, only the branches that actually moved are recalculated.
  • Up to 200 branches are calculated at a time.
  • A badge only applies to the tip it was calculated on: if the branch got new commits, the badge disappears until the next calculation.

The prediction target

In Preferences › Checks › In this repository › Prediction target ("The branch the others are compared with. Empty = automatic: develop with Gitflow, otherwise the remote's default branch."):

  • empty (automatic): Gitflow's develop, if it's initialized; otherwise, the remote's default branch (origin/HEAD, or main, or master);
  • a name: the branch the others are compared with.

The field shows what is in effect, for example "automatic (origin/main)".

From the palette

"Refresh conflict prediction" calculates it right away and says the result:

  • "Conflict predicted with origin/main: feature/login (2), feature/relatorio (1)";
  • "No local branch is expected to conflict with origin/main.";
  • with the prediction turned off, the command is unavailable ("prediction is turned off in Preferences").

Before merge or rebase

When it appears

When you merge or rebase from a branch's menu, when you drag a branch onto another and in a local squash merge: while it calculates, the bar shows "Predicting conflicts…". If the simulation predicts a conflict, the Before merging (or Before rebasing) dialog opens with the Conflict predicted block. With no conflict predicted, the operation goes ahead directly, without a dialog.

Step by step

  1. Start the merge or the rebase normally.
  2. If there's a predicted conflict, read the Conflict predicted block:
    • "Merging feature/login into main is expected to conflict in 2 files:" and the list (up to 40; the rest becomes "… and 12 more");
    • "If you continue, the merge stops at the conflicts and the conflict editor helps you resolve them." (or, in the rebase, "If you continue, the rebase stops at each commit that conflicts.");
    • "The prediction only considers the commits in main and feature/login; uncommitted changes aren't taken into account."
  3. Choose Merge anyway (or Rebase anyway) to go ahead, or Back to cancel.

In the merge request form

In the Create merge request (or Create pull request) form, the app simulates merging the source branch into the chosen target. If there's a conflict, the note "This merge request is expected to conflict with origin/main in 2 files: src/login.ts, src/api/auth.ts. Update the branch with the target first, or resolve it on the server." appears (with more than five files, the first five and "and N more"). The note changes when you switch the target. See Create a merge request.

In Preferences › Checks, Conflict prediction group:

OptionWhat it doesDefault
In the background › Predict conflictsCompares each local branch with the target and marks the ones that would conflict, in the panel and in the graph.On
Before merging or rebasing › Warn when it would conflictThe dialog before merge and rebase ("From the menu or by dragging one branch onto another.").On
When creating a merge/pull request › Warn in the form"Shows the files expected to conflict with the target in the form."On
In this repository › Prediction targetThe branch the others are compared with.Automatic
In this repository › Checks enabled here › Conflict predictionTurns all of this off only in this repository ("Turning one off here only affects this repository.").On

What Versora does in git

A git merge-tree --write-tree between the two commits, with the temporary object database:

bash
git merge-tree --write-tree main feature/login

The exit code says whether the combination was clean; with a conflict, the output carries the files.

How to undo

There's nothing to undo: the prediction only reads. If you go ahead and the merge or rebase stops at a conflict, Abort on the bar puts everything back as it was. See Operations stopped halfway.

Caveats and messages

  • "Conflict prediction needs git 2.38 or newer (installed: 2.30.1). Update Git for Windows to turn it on.": with an old git, the prediction is unavailable. See Git version.
  • "The configured target "develop" doesn't exist in this repository.": the prediction target points to a branch that doesn't exist. Fix it or leave it blank.
  • "There's no default branch to compare with (no origin/HEAD, main or master).": in automatic mode, the app didn't find the default branch. Enter the target.
  • "The histories have no common ancestor.": the two branches have no commit in common; there's no way to predict.
  • "Prediction isn't available in this repository.": the prediction doesn't apply (for example, without a target).

The options are in Preferences › Checks (table above). The company can hide or lock that page through the company policy; see Company policy.

See also

Conflict preview before cherry-pick and revert

Where to find it

The preview runs on its own, before the operation, when you use:

  • Commit menu: Cherry-pick this commit and Revert commit.
  • Selection of several commits in the graph (Ctrl+click or Shift+click) › menu: Cherry-pick 3 commits and Revert 3 commits.

While the simulation runs, the indicator shows "Predicting conflicts…".

Step by step

  1. Choose the cherry-pick or the revert normally.
  2. If the simulation doesn't find a conflict, the operation goes ahead directly, without any question.
  3. If it does, the The cherry-pick will conflict (or The revert will conflict) dialog appears, with the commit and the list of files. For example: "Cherry-picking a1b2c3d ("Corrige o cálculo do frete") will conflict in 2 files:", followed by "• src/frete.ts" and "• src/pedido.ts". With more than eight files, the list ends in "• and 5 more".
  4. With several commits, the dialog says which one conflicts: "commit 2 of 3, b4c5d6e ("…")". The simulation applies the commits in the order the operation will apply them and stops at the first one that would conflict.
  5. Choose:
    • Cherry-pick anyway (or Revert anyway): the operation starts and stops at the conflict, as usual. "If you go ahead, the operation stops at the conflict and you resolve it in the conflict editor (Abort puts everything back)."
    • Cancel: nothing happens.
OptionWhat it doesDefault
Preferences › Operations › Cherry-pick and revert › Predict conflicts before cherry-pick and revertTurns the preview on or off. When it's off, cherry-pick and revert start directly.On

What Versora does in git

For each commit, in order, the app combines the commit's diff (from its parent to it; in a revert, the reverse) with the accumulated result starting from HEAD:

bash
git merge-tree --write-tree --name-only --no-messages -z --merge-base=<parent> <HEAD> <commit>

The objects the simulation creates go into a temporary object database, not into the repository. The exit code says whether the combination was clean or conflicted, and in that case the output carries the files. Nothing changes in the working directory, the stage or the branches.

How to undo

The preview doesn't change anything, so there's nothing to undo. If you go ahead and the operation stops at a conflict, Abort on the bar puts everything back as it was. If you resolve the conflicts and finish the operation (Continue), the cherry-pick or revert goes into Ctrl+Z as a whole, like one that didn't stop. See Operations stopped halfway and Undo and redo.

Caveats and messages

  • The preview needs git 2.40 or newer. With an older git, it doesn't run and the operation goes ahead directly; the git version bar lists "the cherry-pick and revert conflict preview (2.40)" among the unavailable features (see Git version).
  • Like every prediction, it only helps: if it fails or takes longer than 15 seconds, the operation goes ahead as usual, without a warning.
  • Uncommitted changes aren't taken into account: a cherry-pick can still be refused by git if it would overwrite a file you changed.
  • The preview applies to the menu items above. Other ways of cherry-picking, such as dragging a commit onto a branch, have their own checks (see Dragging branches and commits).
  • Preferences › Operations › Cherry-pick and revert: "Simulates the operation in memory first (git merge-tree) and warns you if it will conflict, saying in which files. Needs git 2.40 or newer."
  • The company can hide or lock the Operations page of Preferences (id ergoOps) through the preferences.hidden or preferences.locked policy. See Company policy.

See also

Other conflict predictions

Versora uses the same technique (simulating in memory with git merge-tree) in other places. Each one is explained on its own page:

WhereWhat it warns aboutPage
Local squash mergeThe conflict prediction before the squashSquash
Bulk rebase of outdated branchesThe exact conflict of each branch, leaving out the ones that would conflictHygiene and workflow
Dragging a commit onto anotherRebase with preview and planDragging branches and commits
Applying a patch and applying part of a stashWhether it applies directly, only with 3-way or doesn't applyPatches and Stash