Course Tonight

Course Tonight

Did You Know?

Advanced visual search system powered by Ajax

Chapter 38: Resolving merge conflicts

Estimated reading: 2 minutes 5 views

Section 38.1: Manual Resolution

While performing a git merge, you may encounter a “merge conflict” error. Git will report which files have conflicts, and it’s your responsibility to resolve them.

At any point, you can use git status to see which files still need editing. The status message will provide guidance:

On branch master
You have unmerged paths.
  (fix conflicts and run "git commit")

Unmerged paths:
  (use "git add <file>..." to mark resolution)

     both modified:          index.html

no changes added to commit (use "git add" and/or "git commit -a")

Git leaves markers in the files to indicate where the conflict occurred:

<<<<<<< HEAD: index.html # indicates the state of your current branch
<div id="footer">contact : email@somedomain.com</div>
=======
<div id="footer">
please contact us at email@somedomain.com
</div>
>>>>>>> iss2: index.html # indicates the state of the other branch (iss2)

To resolve the conflicts, you need to edit the area between the <<<<<<< and >>>>>>> markers appropriately. Remove the status lines (<<<<<<<, >>>>>>>, and =======) entirely. Then, use git add index.html to mark it as resolved and git commit to finish the merge.

Leave a Comment

Share this Doc

Chapter 38: Resolving merge conflicts

Or copy link

CONTENTS