Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 2
Message 1 of 4

PR with merge conflicts create on github

Solved! Go to Solution.

Hi,

How does one go about resolving conflicts on a PR created throught the github web ui? I'm familiar on how to resolve commits locally but I'm a bit confused as to how to get the state of the PR on my local. I can't just pull from the branches in question because no commit has been added to these branches. I can only think of redoing the merge locally then pushing it up to the branch in question, but that completely ignores the open PR.

Thanks!!

3 Replies
Commander Lvl 1
Message 2 of 4

Re: PR with merge conflicts create on github

I learn how to solve merge conflict with github so for me is more easy 🙂 

 

1. You get conflict on PR.

 

2. Click the "Resolve conflicts" (on the bottom right):

 

conflict.png

 

3. Take the file (or files) where you had the conflict and delete the unwanted lines with the editor:

 

conflict2.png

 

4. Once you solved the conflict click on "Mark as resolved" (on the right) and then "commit merge" (the green button above):

 

conflict3.png

 

5. This commit merge the branch "master" (in my case) to the "branch-conflict" and solved the conflict:

 

conflict4.png

 

And this is all...

 

Hope this helps 🙂  

 

-Gabriele-

 


Mark helpful posts with Accept as Solution to help other users locate important info. Don't forget to give Kudos for great content!

 

Copilot Lvl 2
Message 3 of 4

Re: PR with merge conflicts create on github

Thanks @Wabri !! That's a great step by step :) Another hypothetical: what should one do where the merge conflict is too complex so github doesn't give you the option to resolve it in the web UI? (where the lovely `resolve conflict` button is disabled)

Solution
Commander Lvl 1
Message 4 of 4

Re: PR with merge conflicts create on github

To solve without the web UI, you need to use the local tools: command line or git client.

 

1. Conflict on PR:

 

firststep.png

 

2. Locally try to merge "branchConflict" to "master" with the merge command (you need to stay in the branch you want to merge):

git merge branchConflict master

(you can do this merge even with a git client like: github desktop or gitkraken) If there are conflicts the output will be something like this:

Auto-merging README.md
CONFLICT (content): Merge conflict in README.md
Automatic merge failed; fix conflicts and then commit the result.

In my case there are only one conflict (in README.md), if there are more than one conflict the output will be more large. This command will create the same lines of the "Resolve conflicts" in github, something like this:

# test

<<<<<<< HEAD
This line will create a new conflict
=======
I try to create conflicts

Hope this can help someone
>>>>>>> master

You can now edit the files where this lines are. Remember that :

  • <<<<<<< HEAD indicates the start of the conflict of the actual branch in my case branchConflict;
  • this ======= is the line to separate branchConflict body with master body (in this case);
  • than will be >>>>>>> master  this line indicates the end of the conflict with the master branch.

NB: in the same file can be more of this lines of conflicts something like this:

<<<<<<< HEAD
conflictBranch 1
=======
master 1
>>>>>>> master

lines not in conflict

<<<<<<< HEAD
conflictBranch 2
=======
master 2
>>>>>>> master
lines not in conflict

<<<<<<< HEAD
conflictBranch 3
=======
master 3
>>>>>>> master
and so on...

 

3. Solve the conflict in the same way you can do with web UI, in my case I done this:

# test

This line will create a new conflict

I try to create conflicts

Hope this can help someone

(simply delete the indicators).

 

4. Add, commit and push this changes and you will find a green button of "Merge pull request":

 

secondyolo.png

 

Ask if you have more problems with conflicts 🙂

 

-Gabriele-

 

Mark helpful posts with Accept as Solution to help other users locate important info. Don't forget to give Kudos for great content!