Resolve conflicts in the current jj commit.
Current status
jj st
$ARGUMENTS
Principles
- A resolution preserves the intent of both sides, not just their text. When
both sides changed the same logic, produce code that satisfies both intents
- Never delete a conflict marker without understanding what each side changed
and why
- The resolved commit passes all checks: format, lint, typecheck, build, test
Workflow
- Read the status above. If there are no unresolved conflicts, tell the user
and stop
- List the conflicted files with
jj resolve --list
- Find where the conflict came from:
jj log -r '::@ & conflicts()' shows the
conflicted ancestry. Read the descriptions of the commits whose changes
collided to understand each side's intent
- For each conflicted file:
- Read the file. Conflicts are materialized with markers (see "Reading
conflict markers")
- If one side should win entirely, run
jj resolve --tool :ours <file> (side
#1) or jj resolve --tool :theirs <file> (side #2)
- Otherwise edit the file to a merge that preserves both sides' intent and
remove the markers. When the markers alone are unclear, view each side's
full file with
jj file show -r <revision> <file>
- Verify all conflicts are gone:
jj resolve --list should report none and
jj st should show no conflicted paths
- Infer verification commands from the project's files (e.g.
package.json,
Makefile, CI config) and run them. If there are none, ask the user
- jj propagates the resolution to descendants of
@ automatically. Run
jj log -r 'conflicts()'; any conflicts that remain are distinct and need
their own resolution
Reading conflict markers
jj materializes conflicts as a diff to apply, not two alternatives:
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-old line
+side #1's replacement
+++++++ Contents of side #2
side #2's version of the region
>>>>>>> Conflict 1 of 1 ends
- The
%%%%%%% section is a diff: lines starting with - are the base, lines
starting with + are side #1's edit, and unprefixed lines are context
- The
+++++++ section is side #2's full content for the region
- To resolve, apply side #1's diff to side #2's content, then reconcile the
parts that still differ
Fixing mistakes
The next jj command snapshots a wrong resolution. To get the conflict back, find
the resolution's operation with jj op log and revert it with
jj undo <operation>. With no argument, jj undo reverts the most recent
operation.
1---2name: jj-resolve-conflicts3description: Resolve conflicts in the current `jj` commit.4---56Resolve conflicts in the current `jj` commit.78# Current status910```!11jj st12```1314$ARGUMENTS1516# Principles1718- A resolution preserves the intent of both sides, not just their text. When19 both sides changed the same logic, produce code that satisfies both intents20- Never delete a conflict marker without understanding what each side changed21 and why22- The resolved commit passes all checks: format, lint, typecheck, build, test2324# Workflow25261. Read the status above. If there are no unresolved conflicts, tell the user27 and stop282. List the conflicted files with `jj resolve --list`293. Find where the conflict came from: `jj log -r '::@ & conflicts()'` shows the30 conflicted ancestry. Read the descriptions of the commits whose changes31 collided to understand each side's intent324. For each conflicted file:33 - Read the file. Conflicts are materialized with markers (see "Reading34 conflict markers")35 - If one side should win entirely, run `jj resolve --tool :ours <file>` (side36 #1) or `jj resolve --tool :theirs <file>` (side #2)37 - Otherwise edit the file to a merge that preserves both sides' intent and38 remove the markers. When the markers alone are unclear, view each side's39 full file with `jj file show -r <revision> <file>`405. Verify all conflicts are gone: `jj resolve --list` should report none and41 `jj st` should show no conflicted paths426. Infer verification commands from the project's files (e.g. `package.json`,43 `Makefile`, CI config) and run them. If there are none, ask the user447. jj propagates the resolution to descendants of `@` automatically. Run45 `jj log -r 'conflicts()'`; any conflicts that remain are distinct and need46 their own resolution4748# Reading conflict markers4950jj materializes conflicts as a diff to apply, not two alternatives:5152```53<<<<<<< Conflict 1 of 154%%%%%%% Changes from base to side #155-old line56+side #1's replacement57+++++++ Contents of side #258side #2's version of the region59>>>>>>> Conflict 1 of 1 ends60```6162- The `%%%%%%%` section is a diff: lines starting with `-` are the base, lines63 starting with `+` are side #1's edit, and unprefixed lines are context64- The `+++++++` section is side #2's full content for the region65- To resolve, apply side #1's diff to side #2's content, then reconcile the66 parts that still differ6768# Fixing mistakes6970The next jj command snapshots a wrong resolution. To get the conflict back, find71the resolution's operation with `jj op log` and revert it with72`jj undo <operation>`. With no argument, `jj undo` reverts the most recent73operation.