Reputation: 103507
How does gitmergetool
works. I have conflicts while doing git merge and now I want to get rid of those merge conflicts and I was browsing SO to get some information on how to do it and there was one suggestion of using git mergetool, I have never used git merge tool but when I do use git merge tool than am getting some local, remotes and backups files for my own files and than I have something like
#*merge*#30260IgX# #*merge*#48883jX#
What does this file(if I may say so) means and how do I can get rid of it as I am not sure of what it is...I do not want to commit this to my repos, any suggestions or work around and also would appreciate if some one can point me to proper resource for using git merge tool
.
Thanks !!!
Upvotes: 3
Views: 587
Reputation: 1326686
"Merging with “git mergetool”" is a starting point, the general theory behind difftool and mergetool being presented in:
"How do I view ‘git diff’ output with visual diff program?"
that being said, for certain standard diff/merge tool, it is even simpler:
"An easier way to set up diff and merge tools for Git on Windows"
First step, install KDiff3.
It's not the prettiest GUI in the world, but once you get used to it it is quite usable and has the added advantage of working quite naturally with Git without having to configure much.Second step, open your
.gitconfig
(in your home directory,C:\Users\(username)
, or down ye oldeDocuments and Settings
path), and add the following:[diff] tool = kdiff3 [merge] tool = kdiff3 [mergetool "kdiff3"] path = C:/Program Files/KDiff3/kdiff3.exe keepBackup = false trustExitCode = false
Now all calls to
git difftool
andgit mergetool
should default to KDiff3.
That's all you need to be good to go!
Much simpler than bothering with all those wrappers.
You will find a good tutorial here (in the excellent gitguru):
The
git mergetool
command allows for the integration of those tools into the merge process. Run after merge conflicts have been identified, it loops through the files that need to be resolved and provides the specified tool with the version information necessary to invoke the 3-way merge.
git mergetool
already includes support for a number open source and freely available merge tools: kdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, ecmerge, and opendiff.Support for additional tools including DiffMerge and Araxis Merge can be added via custom configuration settings provided a command-line call exists:
git config --global mergetool.[tool].cmd [command-line call] git config --global mergetool.[tool].trustExitCode [true|false]
The “
--global
” flag is used, so the setting will apply across all of your Git repositories.The command line needs to accept the following file variables passed in as parameters:
$LOCAL
– Current branch version$REMOTE
– Version to be merged$BASE
– Common ancestor$MERGED
– File where results will be written
git mergetool
will create the versions as temporary files and set the variables appropriately before the tool command-line is executed.If the tool returns a proper exit code after a successful or unsuccessful merge, then the
trustExitCode
setting can be set to true.
Otherwise, set it to false, so you will be prompted whether the merge conflicts for a file were resolved.
The sequence of commands for a merge using mergetool would be
git merge git mergetool -t [tool] git add . git commit
You can specify a default tool via the merge.tool setting
git config --global merge.tool [tool]
This will allow you to just simply call
git mergetool
Upvotes: 2