GIT: command line merging
I have been using git and code repositories for some time now and one of the things I have made an effort of is staying away from all command line git commands apart from;
git init . JetBrains suite of IDE’s have helped me a lot in doing all my git related work. But I think it reaches a point in the life of a Linux lover and an avid developer to step into the unknown world that is not that unknown to the rest of the world.
Personally the most dreaded situation when it comes to git is when a conflict happens or a merge needs to be done, and how to handle that on the command line had eluded me. Thanks to chance and the internet I managed to figure git merging on the command line out.
When git mergetool is invoked with this tool (either through the-t or --tool option or the merge.tool configuration…git-scm.com
git-mergetool is the solution to all this headache and it’s quite easy to configure. When merging files you need a tool to see the difference that exit in the files to be merged and that will help with choosing what should actually be included in the final copy of the file. mergetool specifies the tool/app that git should use to handle merging.
To begin with
git mergetool --tool-help list all possible tools that can be installed and that can work with git.
Beyond Compare 3 , my favorite, has a merge functionality in the Pro edition. The good thing with its merge is that it…stackoverflow.com
After getting the possible tools list you can decide on your own what suits your taste and liking after checking the features it offers and install it then configure git to use it by default. Below we see how to configure p4merge as the default tool. All other possible tool configuration can be found on the internet by making Google your friend.
As per the git documentation temporary files are created when a successful merge has been done and it’ll be a better option to disable them by using
git config --global mergetool.keepBackup false this ensures no
.orig files with the conflict markers will be left behind.