Conflict markers
- Git course
- Intermediate
- Lesson 13/82
- 4 min
Learn the conflict markers and their structure.
What Are Conflict Markers?
When two branches make different changes to the same section of a file, Git may create a merge conflict. Instead of choosing which content to keep, Git marks the conflicting section with special markers.
<<<<<<< HEAD
console.log("Merhaba");
=======
console.log("Hello");
>>>>>>> featureThe contents of the current branch and the branch being merged appear between these markers.
Ours and Theirs Sections
In a conflict, ours refers to the current branch's content, while theirs refers to the content from the branch being merged. The HEAD marker identifies the current branch, and the branch name in the closing marker helps identify the other side.
<<<<<<< HEAD
Ours content
=======
Theirs content
>>>>>>> featureYou can choose either section or combine both to create new content.
Practice Build a Conflict Structure
Create a conflict text in JavaScript. Assign a string containing <<<<<<< HEAD for the current branch, ======= as the separator, and >>>>>>> feature as the closing marker to the conflict variable. Print the text.
Starter code
const conflict = "";
// Çatışma metnini yazdırSample solution
const conflict = "<<<<<<< HEAD\nOurs\n=======\nTheirs\n>>>>>>> feature";
console.log(conflict);Expected output
<<<<<<< HEAD Ours ======= Theirs >>>>>>> feature
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Which section between conflict markers represents the current branch's content?
- The section after the >>>>>>> marker
- The section at the end of the file
- The section after the ======= marker
- The section after the <<<<<<< HEAD marker Correct answer
Explanation: The current branch's content appears after <<<<<<< HEAD. The ======= marker separates the two sides.
2 Complete the Conflict Separator
<<<<<<< HEAD
console.log("A");
____
console.log("B");
>>>>>>> feature
<<<<<<< HEAD
console.log("A");
=======
console.log("B");
>>>>>>> feature
Explanation: The ======= marker separates the current branch's content from the incoming branch's content.
3 Recognize Conflict Markers
| Term | Meaning |
|---|---|
<<<<<<< HEAD |
Start of the current branch section |
======= |
Separates the two sides |
>>>>>>> feature |
End of the incoming branch section |
ours |
Current branch content |