You have been working on a big nice new feature for a few days, or even weeks. All the code is refactored, all the comments are useful, no console prints or debugger lines to be found. It's all ready to ship. You make a pull request. It's almost there. SMACK You have unresolved conflicts. Please fix these before continuing.
The pain is immediate and intense.
Well not to worry. This is a quick step by step guide on how to handle conflicts when merging your branch into, for example, develop. It's simple and foolproof. Here we go.
Do the merge and resolve the conflicts locally:
git fetch git checkout origin/DESTINATION git merge origin/SOURCE
Push the merge up as a new branch:
git push origin HEAD:refs/heads/branch-with-conflicts-resolved
Create new PR in Bitbucket and merge it. You have two options to finish
the merge now that you have resolved all conflicts.
Source: <branch-with-conflicts-resolved> Destination: DESTINATION
- First PR: Source: <branch-with-conflicts-resolved> Destination: branch - Complete that PR. Then in another PR: Source: branch Destination: DESTINATION
- Now you have resolved your conflicts and merged. :-)
It may seem trivial now, but this is one of the most confusing and frustrating things for developers working in a large agile team environment, where the develop and main branches are changing hour to hour, and week to week, respectively. Hope you are well and happy coding!