Course contentsShow
← Git & GitHub
Lesson 48 of 963. Branching and TeamworkFree lesson

Handling Merge Conflicts on GitHub

Learners will resolve blocking conflicts directly within the GitHub web interface to facilitate smooth pull request merges.

In this lesson, you will learn how to resolve blocking merge conflicts directly inside your browser using the GitHub web interface to keep your pull requests moving forward.

When Conflicts Happen in the Cloud

When you open a Pull Request (PR) on GitHub, the platform automatically attempts to merge your feature branch into the base branch. If both branches have changed the same lines in the same file, GitHub will flag a "merge conflict" and block the merge button. While you can resolve these locally, GitHub provides a built-in editor that allows you to address these conflicts without ever touching your command line.

Using the Conflict Editor

When a PR has a conflict, you will see a "Resolve conflicts" button at the bottom of the PR page. Clicking this opens an editor that displays the conflicting files.

GitHub marks the areas of disagreement with standard conflict markers:

  • <<<<<<< HEAD: The content from your base branch (e.g., main).
  • =======: The divider between the two versions.
  • >>>>>>> branch-name: The incoming changes from your feature branch.

To resolve the conflict, simply edit the file in the browser to remove the markers and keep only the code you want to preserve. Once you have cleaned up the file, the "Mark as resolved" button in the top right will become active. Clicking this saves your changes as a new commit on your branch, effectively "fixing" the conflict.

<<<<<<< main
print("Hello World")
=======
print("Hello Team")
>>>>>>> feature-branch

In the example above, you would delete the lines containing the markers and the redundant print statement, leaving only the desired version (e.g., print("Hello Team")).

Once you have resolved all files, click "Commit merge". GitHub will update the branch, the PR status will change to "This branch has no conflicts," and you will be ready to merge your code using the standard green "Merge pull request" button.

Key Takeaway: The GitHub conflict editor allows you to quickly resolve simple overlapping changes directly in your browser, enabling you to bypass local merge cycles and keep your pull request workflow fluid.