In this tutorial we will learn about resolving the merge conflicts in Git and
Github. Git can often resolve differences between merged branches. Usually, the changes are on different lines, or even in different files, which makes the merge simple for computers to understand.
However, sometimes there are competing changes that Git needs your help with to decide which changes to incorporate in the final
merge. Often, merge
conflicts happen when people make different changes to the same line of the same file, or when one person edits a file and another person deletes the same file. You must
resolve the conflict before you can merge the branches.
Lets discuss this scenario in detail:
1. Generally developers or testers create a new branch and modify the
HelloWorld.java in there own branch
2. During the same time if another team member modify the same file and same lines in the
masterbranch in the Github Repository.
3. In Local Repository if the master branch is refreshed from Global Repository and try to merge these changes in the branch
Fix_Bug01which introduces the merge conflicts.
4. Fixing the merge Conflicts by ignoring the lines which are not required.
5. Execute the below commands in the Git bash to resolve the merge conflict.
git commit -m "Commit Message"
In this example we have learnt how to resolve the merge conflicts in Github and Git.