Skip to content
This repository has been archived by the owner on May 29, 2022. It is now read-only.

How to Resolve a Merge Conflict

Bryan Masamitsu Parsons edited this page Sep 25, 2018 · 2 revisions

HOWTO Resolve a merge conflict

Step 1: Avoid conflicts in the first place!

  • Create issues to be tracked in Github and assign them to yourself so no one else works on the same files
  • Work on a feature branch and not on master.
  • Communicate with others about which files you are modifying.
  • Fetch and merge and diff against remote branches before you commit to your local branches
  • Rebase a feature branch to master before you commit to the feature branch
  • Rebase a feature branch before you push

Step 2: You failed to avoid the conflict. Now what?

  • When you execute the merge, you will see a warning or error like this:
    • Merge conflict for file.txt
  • Need to rerun the merge conflict simulation to remind you what is done.
  • Use your favorite text editor to remove conflict blocks of text and the git markup symbols
  • Once you have made your edits, add and commit just like any other file change:
    • git add problem_file.cpp
    • git status should show that the file is no longer of state "conflicted"
    • git commit problem_file.cpp