We are working on a collective team project where using GIT commit system. We got a issue with merge, how to resolve merge conflicts in git.
Why does merge conflicts occur in git and how we can resolve merge conflicts in git?
Sign Up to our social questions and Answers Engine to ask questions, answer people's questions, and connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
We can resolve merge conflicts in GIT by using VIMdiff command tool. Initially we have to use mergetool command, so that is there any merge conflicts in GIT they’ll get resolved easily.
install anyone of the following: meld, opendiff, kdiff3, tkdiff, xxdiff, tortoisemerge, gvimdiff, diffuse, ecmerge, p4merge, araxis, vimdiff, emerge.
As stated above the above example is shown with vimdiff.
1) Run below commands
git config merge.tool vimdiff
git config merge.conflictstyle diff3
git config mergetool.prompt false
By executing the above three commands,we are telling the terminal to fix vimdiff as the default merge tool.
2) git mergetool ( run this command, so that it will open GUI options for the user to click.
╔═══════╦══════╦════════╗
║ ║ ║ ║
║ LOCAL ║ BASE ║ REMOTE ║
║ ║ ║ ║
╠═══════╩══════╩════════╣
║ ║
║ MERGED ║
║ ║
╚═══════════════════════╝
Now press ctrl+w. followed by j, so that you never get to merged section.
3)You could edit the MERGED view the following way
If you want to get changes from REMOTE
:diffg RE ( remote)
:diffg BA: (base)
diffg LO: ( local)
You need to edit something and then save it so that all the merge conflicts will get resolved now.
Save, Exit, Commit and Clean up.
See also how to delete unpublished git commits and get rid of them permanently?