git needs your help in deciding which change needs to be incorporated in the final merge of the branch. Git can often resolve the difference between branches and merges the branches automatically. Usually, the changes are on different lines or even different files. This makes it easy for the computer to understand. However, there are few changes that git cannot resolve without the user’s help. This happens usually when different people make changes to the same line in a file or a person edits the file while another deletes it. This causes a conflict of changes while merging the branch. We need to resolve all the conflicts before we merge a pull request to the git server. If we have a merge conflict between the compare branch and the base branch, we can see the files and the changes that caused the conflict above the merge pull request button. The merge pull request button is deactivated until the conflict is resolved. To resolve the merge conflict, we need to manually edit the conflict inflicted changes. We must edit and specify the final changes that are to be merged. We can either resolve the changes in the local computer and then push to the repository or we can directly edit the changes in the conflict editor of the git server like github or gitlab. If we have any conflicts in the command line, we cannot push the local changes to the server until we resolve the merge conflicts. If we try to merge the branches with a conflict from the command line, we will be getting an error message. A sample error message is given below.
git merge BRANCH-NAME Auto-merging example.md CONFLICT (content): Merge conflict in example.md Automatic merge failed; fix conflicts and then commit the resultOnce the conflicts are resolved and the changes are pushed, be happy. You can now merge the branch with no worries.]]>