Learn Github PR/Merge Conflicts in Seconds

Learn Github PR/Merge Conflicts in Seconds

Wondering how do I contribute to open source? Did you ever notice the Pull Requests tab when you visit some project on GitHub? Yeah, there lies the crux. Now assuming you know about Github, wait again? Assumptions are dangerous. So, let me know in the comments if you work on GitHub every day. Let continue with the assumption.

Prefer to watch instead of reading here you go:

Pull requests are the most used feature of GitHub. These are basically simple branches that get powered up (OP #gamers will know) to become candidates to enter the sea of code that our main branch holds. You can raise any branch to become a Pull Request and that's why it's said 'raise a PR'. (OP #again). Now once you create a PR it will be peer-reviewed and then merged into the sea of code. Just like the titanic, merge conflicts are the icebergs that we will need to resolve/dodge. This requires you to know the codebase in and out.

What is a merge conflict? Let's see.

Let's look at this PR from here: github.com/adityak74/test-open-source-app/p..

Screen Shot 2021-04-24 at 12.09.25 AM.png

Let's look at these three commits in detail to understand what happened.

  1. This is the first commit. Adding two lines to the Readme file. Screen Shot 2021-04-24 at 12.11.58 AM.png
  2. Conflicting commit iceberg clash happens when the contributor tried to commit to the same file as the author modifies as well. Screen Shot 2021-04-24 at 12.16.33 AM.png
  3. Now to resolve this merge conflict issue the contributor will merge the main branch from the author to his branch. This resolves the conflict and the PR is marked safe to merge. Note the lines 5,6 here!. These lines have been modified manually to resolve to one of the changes. Screen Shot 2021-04-24 at 12.18.36 AM.png

Finally, the PR is approved and merged. Screen Shot 2021-04-24 at 12.19.52 AM.png