I hope this helps: click here
For difficult situations, you can do either one of them:
1. Resolve the conflict, reverse-integrate the changes from the target branch which will create additional merge commits
2. Rebase on the target branch that will give you a clean history
Here is a plugin that will help: click