development branch. Likewise, keep your feature branch up to date by merging/rebasing the development branch into your feature branch. Merging frequently will make sure that you avoid having to resolve a large and confusing conflict.
Good communication can help avoid most merge conflicts. In the planning phase make sure that as few tasks as possible overlap for team members. When you can’t avoid that, make sure you talk with the developers about what they want to do next and how. You could work together on a problem, decide a common strategy, or plan on who is going to do what first. The latter two options become feasible when you develop and merge in shorter increments as you aren’t blocked by the other person for too long. If the merge conflict is unavoidable and messy try to resolve the conflict together with the team member who made the changes. Also, don’t forget to tell others if you plan on refactoring substantial parts of the code base.
Do not forget to follow code conventions and to configure your editor accordingly. Whitespace at the end of lines, the use of spaces/tabs for indentation, and much more are can cause a merge conflict unnecessarily. You can enforce your conventions by using a pre-commit hook or a continuous integration service. And please ignore compiled files, because if they do change then, no-one knows how they are supposed to look.
Using many short files rather than long ones reduces the probability of working on the same file. Here are a few ways you can split up a file:
Obviously creating too many files could lead to an unclear structure. You can move files into subfolders which add a little bit more structure. Or you could move them into standalone modules and reuse them later.
Avoid doing too much in one line of code, which makes it harder to select the appropriate changes in a merge conflict. This goes hand in hand with long methods. Just avoid them.
There is no silver bullet for mitigating merge conflicts. However, I hope that this will help you to prevent many of the unnecessary ones. Feel free to open a PR to add your own advice.