Skip to content

Second merge: Let's try a conflict#1

Open
github-learning-lab[bot] wants to merge 1 commit intomasterfrom
update-config
Open

Second merge: Let's try a conflict#1
github-learning-lab[bot] wants to merge 1 commit intomasterfrom
update-config

Conversation

@github-learning-lab
Copy link

Step 3: Resolve a simple conflict

You may merge a lot of pull requests before you encounter your first merge conflict. That’s because Git is really smart when it comes merging. However, most of the time, you won't know you have a conflict until you create the pull request.

This branch is a great example. In this scenario, two of our friends have been working in this repository. They both created branches, changed the _config.yml file and opened pull requests. One pull request merged in to master without any problem, but now the other pull request shows a conflict.

The history of master and this branch look something like this:

deviated branches

However, since this pull request also changes the same lines in the _config.yml file, there is a merge conflict.

Let's help our friends resolve this conflict.

⌨️ Activity: Resolving your first conflict

Here's how you can fix this merge conflict:

  1. In the "This branch has conflicts that must be resolved" section of the Pull Request (below, keep scrolling), click the Resolve conflicts button.

  2. Look for the highlighted sections that begins with <<<<<<< update-config and ends with >>>>>>> master. These markers are added by Git to show you the content that is in conflict.

  3. Remove the changes made on the master branch by deleting all of the content below the ======= and above >>>>>>> master.

  4. Next, remove the merge conflict markers by deleting the following lines:

    <<<<<<< update-config
    =======
    >>>>>>> master
    
  5. Optional: If you're thinking about using this resume, you can edit the _config.yml file with your own information now. Change any of the lines within the file, even outside of where the markers were. More about this below.

  6. With the merge conflict markers removed, click Mark as resolved.

  7. Finally, click Commit merge.

Sometimes the correct way to resolve a merge conflict is to add completely different content or to keep all of the changes made on both branches. This is why Git needs a human to look at the code and make the proper fixes.


Watch below for my response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant