Menu
Coddy logo textTech

Resolve A Conflict

Part of the Version Control section of Coddy's Terminal journey — lesson 38 of 58.

Aborting is sometimes the right move, but most of the time you want to actually resolve the conflict and finish the merge.

Resolving a conflict is a three-step ritual:

  1. Open the conflicted file. Replace the marker block with the version you want (or a combination).
  2. Stage the resolved file with git add.
  3. Finalize the merge with git commit.

You can use a script to overwrite the file with the resolved content directly, which is exactly what you will do in this lesson (no editor needed).

If you forget to git add the resolved file, the commit will fail and tell you the file is still marked as unmerged.

challenge icon

Challenge

Medium

Set up a conflict on notes.txt exactly like the previous lesson:

  • Initial commit on main with content hello
  • On branch alt: change to hi from alt, commit
  • Back on main: change to hi from main, commit
  • Run git merge alt (it will conflict)

Resolve the conflict by overwriting notes.txt with the line hi from both. Stage the file and finalize the merge with the message Resolve notes. Print the final contents of notes.txt.

Cheat sheet

To resolve a merge conflict:

  1. Edit the conflicted file — remove conflict markers and keep the desired content.
  2. Stage the resolved file: git add <file>
  3. Finalize the merge: git commit
git add notes.txt
git commit -m "Resolve conflict"

If you skip git add, the commit will fail with the file still marked as unmerged.

Try it yourself

Terminal
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Version Control