Before merging your branch to the main branch (develop, master, whatever), it occurs that your branch is many commits behind the destination branch and somebody pushed changes which have conflicts with yours. Before pushing your changed files you have to sync your branch with the destination branch and in case, that there are files with conflicts you have to resolve them. If you are a fan of git bash or command line, there are 5 steps how to manage merge.
1.Checkout the temporary branch with your changes.
This branch is created, when there are detected conflicts with your origin branch which are not possible to resolve with auto-merging .
git checkout <temporary-branch>
2.Merge destination branch to your detached branch.
git merge remotes/origin/<destination-branch>
This command will merge all files which can merge. In others, there are marked lines of code, which have to be merged manually
Compare yours and incoming changes and resolve them. If you have finished, you can mark the resolved file with git add.
git add 'path/resolved-file'
4.Commit resolved files
If you commit your resolved files you are in the detached branch so you have to push it to your branch.
5.Push detached branch to your branch
git push origin HEAD:<name-of-your-branch>
If it is successful, your branch is in sync with destination branch. You can continue with creating pull request or merging your branch to destination branch.
Follow me on Twitter