๐ŸŽ“ A1Learner
๐Ÿ”
0 of 50 lessons completed

Resolve a Conflict

Resolving a conflict means choosing the lines to keep. You edit the file, stage it, and finish the merge.

The file holds both versions

Edit the file first: keep the two-litre line and delete the markers and the one-litre line.

$ cat notes.txt

Stage the choice and finish

Staging marks the conflict as resolved. The commit finishes the merge.

$ git add notes.txt
$ git commit -m "Resolve milk size conflict, keep two litres"

The history shows the join

The merge snapshot sits on top, with the choice inside it.

$ git log --oneline --graph

Example

$ git add notes.txt
$ git commit -m "Resolve milk size conflict, keep two litres"
$ git log --oneline --graph

Key points

  • Open the file and find the markers.
  • The part above the markers is yours. The part below is theirs.
  • Delete the markers and the lines you do not want.
  • Keep the lines you want, exactly as they should read.
  • Stage the file to mark the conflict as resolved.
  • Commit to finish the merge.
  • The merge snapshot records the choice you made.

Here, staging and committing finish the merge. The graph shows the two milk lines joined into one snapshot.

Try it Yourself

Edit the code, then press Run.

Running is simulated

Exercise

What marks a conflict as resolved?