Understanding Github Conflicts
Let’s imagine a case where two developer working on one respository by creating 2 different branch and same code line and both of them pulled the file to main repository, Now the github is good understanding the code and merge the conflicts automatically but it fails understanding if developer has put any comments. Now Lets look into How to resolve merge conflicts in github.
Table Of Content
Lets resolve Github Conflicts
Step 1: In case if you dont know how to do pull request in Github, refer this blog. Once you press compare and pull request, Github will look into the possibilties of merging that itself if not it will show developer to solve the resolve conflicts Manually.
Step 2: Click on Resolve Conflict Button
Step 8: Lets look into how to resolve these github conflicts. As highlighted in 1 there are 16 conflicts here, and these conflicts are highlighted as below. Here Github found there are codes to merge in the same lines, <<<<< sanjay represents your branch. Now if you want to keep the changes as it is just delete the below lines from your entire code base. Click and backspace will do the work.
<<<<<<<< sanjay ======== >>>>>>> main
Step 9: Once all the conflicts has been removed, you can see the button Mark as resolved became active.
Step 10: Commit Merge to do this merging with the main branch
Step 11: In the next page you can see the merge pull request option, you also have an option to save this draft, here we will proceed with merging the pull request.
Now you can see the branch Sanjay has been merged to the main branch. You have successfuly resolved git conflicts and merged changes in branch to main branch.
FINAL VERDICT :
In conclusion, I hope you enjoyed reading this article on “How to do resolve conflict while merging in GitHub?”. Refer the complete Github tutorial on recodehive.com. Signing off Sanjay Kv