Survive a Merge Conflict
Reading conflict markers, choosing content, deleting markers, and committing a resolution.
Challenge Coach audio
Challenge Coach Transcript
Alex and Jamie walk through this challenge step by step.
Alex: Welcome back. Challenge 7 is called Survive a Merge Conflict, and I love that title because it names the feeling pretty honestly. A conflict can look alarming the first time, but it is usually just Git saying, "I found two edits in the same place, and a person needs to decide."
Jamie: And this is happening inside the Day 1 Learning Room, right? The private repository each learner gets for issues, branches, commits, pull requests, and merges.
Alex: Exactly. Challenges 1 through 6 are the live core path, and Challenge 7 is available as stretch practice or async follow-up if the room needs more time. In this challenge, a facilitator intentionally creates the conflict so you can practice on something safe.
Jamie: That already lowers the pressure. If it appears, it is not because you broke the project. It is because the exercise was set up to teach you how to read it.
Alex: A merge conflict happens when two changes touch the same part of the same file in different ways, and Git cannot automatically choose the right result. If one person edits line 12 to say "Submit form" and another edits that same line to say "Send message," Git stops and asks for a human decision.
Jamie: So Git can still merge lots of things on its own, like changes in different files or different parts of a file. The conflict is the overlap.
Alex: Right. Common causes include two people editing the same line, one person deleting a file while another edits it, two people reorganizing the same section, or a pull request staying open so long that the main branch moves far ahead.
Jamie: That last one feels very real. The longer a branch sits around, the more chances the project has to change underneath it.
Alex: You can prevent many conflicts by keeping branches short-lived, syncing with main often, and talking with teammates about who is editing what. Small pull requests help too, because a focused change gives Git and reviewers less to compare.
Jamie: And avoid those giant formatting sweeps unless the team agrees first. Reformatting a whole file can make Git think every line changed, even if the actual idea was tiny.
Alex: Yes. Pull before you push, work in separate files when possible, and use Draft PRs when you want early visibility before the work is ready to merge. In Git, a fast-forward merge is the easy case where your branch is simply ahead of main with no competing history, so Git can move the pointer forward without creating a special merge commit.
Jamie: But conflicts are not always bad news. Sometimes they catch the exact place where two ideas need to be reconciled.
Alex: Exactly. A conflict can protect the project from silently losing someone's work. And as AI-assisted workflows become more common, this skill matters there too: an AI agent may generate a change that overlaps with human-written code, and resolving the conflict is part of supervising that work safely.
Jamie: What should a learner expect to see in Challenge 7 itself?
Alex: You start from your assigned Challenge 7 issue and your existing pull request. The facilitator triggers the conflict, and then the pull request may say something like "Can't automatically merge" or "This branch has conflicts." Look near the merge area for a "Resolve conflicts" button.
Jamie: And if the conflict is not there yet, waiting for the facilitator signal is a valid move. There is no need to hunt for a problem that has not been created.
Alex: Yes. The issue description tells you which practice file contains the conflict markers. The branch guidance is the same short-lived pattern from the previous challenge, something like fix/yourname-issueXX.
Jamie: Learners can do this in the browser on GitHub.com, and people who cloned their Learning Room can use VS Code or the terminal instead.
Alex: The web editor is the main path for this challenge because it keeps the workflow close to the pull request. VS Code and local Git are good alternatives if you are already set up locally.
Jamie: Let's talk about the scary-looking part: the actual markers in the file.
Alex: Git writes three marker lines into the file. You may hear or read a line that starts with seven less-than signs, then a middle separator line of equals signs, and then a closing line that starts with seven greater-than signs. In one common PR example, the first section is the HEAD version, often the version on main, and the second section is your branch version.
Jamie: But the labels can depend on the operation, right? In a local merge, "current" and "incoming" may not mean what a learner assumes.
Alex: Exactly. Read the labels and read the surrounding text instead of trusting memory alone. The content between the first marker and the equals line is one version, the content between the equals line and the closing marker is the other version, and the marker lines themselves are never final content.
Jamie: So the job is not to delete the whole conflicted area. The job is to decide what the final file should say.
Alex: Here is a simple example. Before resolution, the file might contain "Welcome to the Learning Room! This is the main branch version" on one side, and "Welcome to the Learning Room! This is my improved version with more detail" on the other. A valid resolved file might keep the improved sentence, keep the main version, or write a new combined sentence that uses ideas from both.
Jamie: All three can be correct if the final text is meaningful and the project is better for it. The mistake is leaving the conflict markers behind.
Alex: On GitHub.com, open your pull request, find the message about conflicts, and choose "Resolve conflicts." GitHub opens an editor and highlights the conflicted area. Read both versions carefully before changing anything.
Jamie: For finding the area quickly, search for the marker that starts with the less-than signs. In the browser, Ctrl+F works well, and in VS Code the editor find tools can jump you there too.
Alex: Then make the content decision: keep one side, keep the other side, or combine them into one clean paragraph or code block. After that, remove every marker line: the opening marker, the equals separator, and the closing marker.
Jamie: I like saying "every marker line" because there are usually three types to check for. Search for the less-than marker, the equals separator, and the greater-than marker before you commit.
Alex: Once the file reads cleanly, use "Mark as resolved," then commit the merge resolution. Your pull request should update, and if everything is clean, it should become mergeable again.
Jamie: The automated check is looking for practical evidence too. No conflict markers should remain, and the file should still contain real, meaningful content.
Jamie: What changes if someone uses VS Code instead of the browser?
Alex: VS Code highlights conflict regions and may offer actions like "Accept Current Change," "Accept Incoming Change," and "Accept Both Changes." Those buttons are helpful, but still read the actual text because current and incoming depend on the merge situation. After accepting both, you may still need to edit the result so it reads naturally.
Jamie: So the button can start the resolution, but it does not replace judgment.
Alex: Exactly. Save the file, review it, and commit the resolution. If you are using Source Control in VS Code, the changed file should appear there after you save.
Jamie: And for terminal users, what is the local Git shape of this?
Alex: From your Learning Room folder, you would update main, switch back to your feature branch, and merge main into it. If Git reports a conflict, use git status and look for files listed as both modified. Open each conflicted file, remove the markers, keep the content you want, and save.
Jamie: Then the resolution becomes a normal commit.
Alex: Right. Run git add for the file, commit with a message such as "Resolve merge conflict in welcome.md," and push. Your pull request on GitHub updates automatically, and you can check the diff, the PR status, and any validation checks.
Jamie: What if someone gets stuck halfway through and feels like they made it worse?
Alex: First, that is normal. If you do not see a conflict, the facilitator may not have triggered it yet. If you cannot find the button, look in the pull request conversation near the merge section, or search the page for "Resolve conflicts."
Jamie: And if the hard part is deciding which text to keep?
Alex: Read both versions aloud if that helps. Keep the clearer version, combine both if both add value, or ask the facilitator for a sanity check. If you accidentally delete too much, undo with Ctrl+Z and work through that conflicted block again.
Jamie: What about the dreaded bot message that says markers are still there?
Alex: Search the file for all three marker patterns: the less-than line, the equals line, and the greater-than line. There should be zero results for the conflict markers. If you want another comparison point, use the reference solution for Challenge 7 or ask someone to review the final text.
Jamie: The chapter also mentions learning cards for different ways of working.
Alex: Yes. There are cards for visual and mouse users, low vision users, NVDA and JAWS on Windows, VoiceOver on macOS, and CLI users. Open the ones that match your setup, and if you need official background, the GitHub guide to resolving merge conflicts and the Git book's basic merge conflict chapter are reliable references.
Jamie: Once the conflict is resolved, what evidence does the challenge ask for?
Alex: Your pull request should be linked to the issue, usually with "Closes #XX" in the body, and the title can be something like "fix: resolve conflict markers in filename." In the description, include one or two sentences saying which content you kept, or whether you combined both, and why.
Jamie: The issue also asks for a plain evidence comment, right? Something like the conflict was in this file, I chose to keep this content, and I resolved it by removing the markers.
Alex: Yes. There is also a peer simulation check: compare your resolution with the facilitator's conflict seed, or with a buddy if you have one. Two valid resolutions can keep different wording, as long as the final file is clean and intentional.
Jamie: You are done when the pull request passes the bot checks, has no marker lines, and is ready to merge. If live time runs out, this is a good async follow-up because the steps leave a clear trail.
Alex: And in the broader Day 1 path, that trail matters. You have used an issue, a branch, a commit, a pull request, a reviewable change, and now a merge conflict resolution inside your own Learning Room.
Jamie: Let me try the short version. A conflict means Git found overlapping edits and needs a human choice, not that the project is ruined.
Alex: Yes. Read both sides, choose or combine the content, delete the marker lines, save, commit, and verify that the pull request is clean.
Jamie: And the professional habit is staying calm enough to read what is actually there.
Alex: Exactly. Merge conflicts are a normal collaboration checkpoint. If you can identify the markers, make a deliberate content decision, and leave the file meaningful, you have survived Challenge 7.
Reference Solution
Solution Reference: Challenge 7 -- Resolve a Merge Conflict
This shows what conflict markers look like and how to resolve them.
What conflict markers look like
When Git cannot automatically merge two changes to the same lines, it inserts markers:
<<<<<<< HEAD
Welcome to the Learning Room! This is the main branch version.
=======
Welcome to the Learning Room! This is my improved version with more detail.
>>>>>>> fix/welcome-update
The three sections
- Between
<<<<<<< HEADand=======: The version on the branch you are merging INTO (usually main) - Between
=======and>>>>>>>: The version on YOUR branch - The marker lines themselves: Must be deleted -- they are not content
Example resolution
Before (with conflict markers):
<<<<<<< HEAD
Welcome to the Learning Room! This is the main branch version.
=======
Welcome to the Learning Room! This is my improved version with more detail.
>>>>>>> fix/welcome-update
After (resolved):
Welcome to the Learning Room! This is my improved version with more detail.
Decision process
You chose one of three options:
- Keep yours: Delete the HEAD section and all markers, keep your changes
- Keep theirs: Delete your section and all markers, keep the HEAD version
- Combine both: Write new text that incorporates ideas from both versions, delete all markers
All three are valid. The choice depends on which version is better for the project.
On github.com
GitHub offers a conflict editor directly in the browser:
- Click "Resolve conflicts" on the PR page
- The editor highlights conflicting sections
- Edit the file to remove markers and keep the content you want
- Click "Mark as resolved" then "Commit merge"
In VS Code
VS Code highlights conflicts and offers clickable options above each conflict:
- "Accept Current Change" (HEAD version)
- "Accept Incoming Change" (your version)
- "Accept Both Changes" (keeps both, you edit after)
What matters
The learning objective is understanding that conflicts are normal and resolvable. If you removed all conflict markers and the file makes sense, you completed this challenge.
Authoritative Sources
Use these official references when you need the current source of truth for facts in this chapter.
Section-Level Source Map
Use this map to verify facts for each major section in this file.
- What conflict markers look like: GitHub Docs, home, GitHub Changelog
- Example resolution: GitHub Docs, home, GitHub Changelog
- On github.com: GitHub Docs, home, GitHub Changelog, About Git, GitHub flow, About pull requests
- In VS Code: GitHub Docs, home, GitHub Changelog
- What matters: GitHub Docs, home, GitHub Changelog