What is Merge Conflict :
Merge conflicts Happen when we try to merge two branches, which have same file updated by two or more developers .
If you try to merge the bugfix branch then git can not determine which changes to determine in the merge version .
Hands on :
touch demo
nano demo
Original code (Master)
$git branch dev1
$git branch dev2
$git checkout dev1
nano demo
Original code(Master)
code added by dev1
$git add .
$git commit -m "code added by dev1"
$git checkout master
$git merge dev1
$git checkout dev2
nano demo
Original code(Master)
code added by dev2
$git add .
$git commit -m "code added by dev2"
$git checkout master
$git merge dev2
It displays a merge conflict error
This because in master we have a uncomplete code
- so we have to manually fix this :
$git mergetool
- Change the final code that you want and then save it .
$git status
$git commit -m "merge conflict resolved"
Top comments (0)