Ah, the dreaded resolve conflicts message. You've finished crafting the perfect code, just a quick merge in of master (ahem, main) before you submit your PR, and then... 💥
If only there was an early warning system for merge conflicts so you could be better prepared or even avoid the conflicts in the first place I hear you say? Well if you are a VS Code user today is your lucky day!
Firstly, you'll need to install and set up GitLive, then you should see this icon in the top right-hand corner.
It will be disabled if the file open in the editor is not from git or there are no other changes to it from contributors working on other branches (aka you are safe from conflicts). If it's enabled there will be one or more change indicators in the gutter of the editor.
These will show you where your teammates have made changes compared to your version of the file and even update in real-time as you and your teammates are editing.
If you've made a conflicting change you will see the bright red conflict indicator. These conflicts can be uncommitted local changes you have not pushed yet or existing changes on your branch that conflict with your teammates’ changes.
Hover your mouse over the code in the affected lines to see the diff between your version and theirs, the branch the offending changes are from, and the issue connected to that branch if there is one.
From this popup you can also cherry-pick your teammate’s change directly from their local version of the file. For simple conflicts this can be a quick way to resolve them as identical changes on different branches will merge cleanly.
Unfortunately, it's not always possible to resolve a conflict straight away but with the early warning, you'll be better prepared, avoiding any nasty surprises at merge time!