It opens a GUI that steps you through each conflict, and you get to choose how to merge. Sometimes it requires a bit of hand editing afterwards, but usually it’s enough by itself. It is much better than doing the whole thing by hand certainly.
As per Josh Glover’s comment:
doesn’t necessarily open a GUI unless you install one. Running
git mergetoolfor me resulted in
vimdiffbeing used. You can install one of the following tools to use it instead:
Below is the sample procedure to use
vimdiff for resolve merge conflicts. Based on this link
Step 1: Run following commands in your terminal
git config merge.tool vimdiff git config merge.conflictstyle diff3 git config mergetool.prompt false
This will set vimdiff as the default merge tool.
Step 2: Run following command in terminal
Step 3: You will see a vimdiff display in following format
╔═══════╦══════╦════════╗ ║ ║ ║ ║ ║ LOCAL ║ BASE ║ REMOTE ║ ║ ║ ║ ║ ╠═══════╩══════╩════════╣ ║ ║ ║ MERGED ║ ║ ║ ╚═══════════════════════╝
These 4 views are
LOCAL – this is file from the current branch
BASE – common ancestor, how file looked before both changes
REMOTE – file you are merging into your branch
MERGED – merge result, this is what gets saved in the repo
You can navigate among these views using ctrl+w. You can directly reach MERGED view using ctrl+w followed by j.
Step 4. You could edit the MERGED view the following way
If you want to get changes from REMOTE
If you want to get changes from BASE
If you want to get changes from LOCAL
Step 5. Save, Exit, Commit and Clean up
:wqa save and exit from vi
git commit -m "message"
git clean Remove extra files (e.g. *.orig) created by diff tool.