Resolving a Git Merge Conflict by Behavior

A conflict indicates that Git could not automatically choose a combined result for part of the history. The resolution should express current intent.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Read the shared base
  2. Verify the chosen dependency
  3. Rebuild the shared behavior before choosing the text
  4. Validate syntax and domain effects after editing

Read the shared base

If one branch changes a limit from 10 to 12 and another from 10 to 15, either value alone may ignore a policy decision. Compare the base and both edited versions using small diffs.

Verify the chosen dependency

Other code can depend on the new limit differently on the two sides. Update or confirm those callers, then run focused and integration tests on the combined snapshot.[1]

Rebuild the shared behavior before choosing the text

One branch changes an export's date format while another adds a time zone field in the same function. The merged result may need both behaviors. Compare the common base, each branch's goal and a concrete expected export. See reviewing a Git diff.

Base output: date only
Left requirement: revised date format
Right requirement: time zone present
Integrated example should show both

Validate syntax and domain effects after editing

Deleting conflict markers is only an editing step. Parse the result, run tests and check the two behavior changes jointly. Review staged content so the resolved snapshot actually matches what was tested.

References

  1. Scott Chacon and Ben Straub, Pro Git ↩