Resolving conflicts¶
Audience: team users who pull or merge · ~6 min read · Prerequisites: Source Control pane
What it is¶
A merge conflict happens when git cannot combine two edits to the same part of a file. Git then writes
markers into the file (<<<<<<<, =======, >>>>>>>) and waits for you. A model file is plain text, so it
can contain these markers too.
Git merges the text of the files. For a conflicted model file (.model.py / .model.js) struktJS offers a
node-level resolver instead: it re-merges the three versions git keeps (common ancestor, yours, theirs) as
trees, merges every non-overlapping change automatically, and asks you only about the nodes that really
overlap. Other files, and model files that cannot be read as trees, are resolved by editing text. This page
shows both.
When you'd use it¶
After Pull, after applying or popping a stash, or after a merge you started in the Terminal.
What happens in each pane action¶
| Action | On conflict |
|---|---|
| ⇄ Merge into current branch | Aborted automatically (git merge --abort), the pane shows an error, your files are unchanged. |
| Revert | Aborted automatically, error shown. |
| Pull | Not aborted. Conflict markers stay in the files. |
| Apply / Pop a stash | Not aborted. Markers stay in the files. |
| Anything you run in the Terminal | Whatever git does. |
So the pane never leaves its own merge or revert half done, but a Pull can (and a stash apply leaves markers without a merge). While a merge is unfinished the pane shows A merge is in progress. with an Abort merge button.
What you will see¶
- The conflicted file is listed in its own Merge Conflicts group with a UU badge (or
AA,DD,AU,UA,DU,UD). Its row has a ✓ Stage (mark resolved) button; there is no Unstage or Discard for it. Commit stays disabled while the group is not empty. - If that model is open in the editor, a message says the file on disk "can't be read" or "contains a syntax error", and that "saving is paused until it is fixed". The editor keeps your in-memory model and leaves the file alone, so it does not overwrite the markers.
- Nothing is lost: the conflicting versions are both in the file text, and git still holds all three versions.
Resolve by node (model files)¶
- Click the conflicted model file in Merge Conflicts. Instead of a text diff, the pane opens Resolve conflicts by node.
- It says how many conflicts need a decision; everything else is already merged. Each conflict shows what the node looks like on Ours and on Theirs, rendered like the editor.
- Choose Keep ours or Keep theirs for each one. When both sides added different statements at the same place you can also choose Keep both (ours first, then theirs).
- Apply and mark resolved turns on once every conflict has a choice. It writes the merged file and stages it, so the row moves to Staged Changes. Then commit as below.
What counts as a conflict: the same statement changed differently on both sides, one side deleting what the
other changed, both sides adding different statements at the same position, a differing model root in a file
with several roots, or a file header line (package, modelimports, format, langversion) changed to two
different values. Edits to different parts of one statement merge on their own, so do edits to different
statements.
If the three versions cannot be read as trees, the pane says why and offers Use our whole file and Use their whole file. If one side deleted the file there is nothing to merge; use Stage to keep the remaining version.
How to resolve by hand¶
- Look at the Merge Conflicts group in the pane (or run
git statusin View > Tool Windows > Terminal). - Choose how to resolve (for a model file, prefer Resolve by node above):
- Give up: click Abort merge in the pane (it appears while the merge is unfinished). For a single
file, use
git checkout -- <file>in the Terminal. - Fix by hand: open the
.model.py/.model.jsfile as text (Explorer, or Open With… on the file), keep the lines you want, delete the three marker lines, and save.
- Give up: click Abort merge in the pane (it appears while the merge is unfinished). For a single
file, use
- Click ✓ Stage (mark resolved) on each fixed file. The row moves from Merge Conflicts to Staged Changes.
- Type a message and click Commit (enabled once nothing is conflicted) to finish the merge.
- Click ⟳ Refresh in the pane. Open models are re-checked against the disk; if you had the model open, it reloads with the merged content.
Tips for model files:
- Keep each statement on its own line when you edit by hand; the file must still parse. If it does not, the editor keeps saying saving is paused. Fix the syntax first.
- The
model.jsonbeside the model is JSON: make sure it is still valid JSON after you remove markers. - Use the tree diff afterwards to check the result against the last commit.
Every control¶
| # | Button/Option | What it does | Shortcut | Gotcha |
|---|---|---|---|---|
| 1 | UU badge | Marks a file with unresolved conflicts. | Listed under Merge Conflicts. | |
| 2 | ✓ Stage (mark resolved) | Runs git add on the file. |
Do it after removing the markers; git does not check for them. | |
| 3 | Abort merge | git merge --abort after a confirmation. |
Only while a merge is unfinished. Discards the merge, including your resolutions so far. | |
| 4 | ⟳ Refresh | Re-reads the state after you fixed things. | ||
| 5 | View > Tool Windows > Terminal | Still the place for git checkout -- <file> and anything else the pane lacks. |
||
| 6 | Resolve conflicts by node | Opens when you click a conflicted model file. Lists only the overlapping nodes, with Ours and Theirs side by side. | Needs the file to be readable as a model on all sides; otherwise only the whole-file choices appear. | |
| 7 | Keep ours / Keep theirs / Keep both | Decides one conflict. Keep both exists only where both sides added different statements at the same place. | Apply stays off until every conflict has a choice. | |
| 8 | Apply and mark resolved | Writes the merged model file and runs git add on it. |
Refuses any file git does not list as conflicted. |