gitmergetool
是如何工作的。我在执行 git merge 时遇到冲突,现在我想摆脱那些 merge 冲突,我正在浏览 SO 以获取有关如何执行此操作的一些信息,并且有人建议使用 git mergetool,我从未使用过 git merge 工具但是当我使用 git merge 工具而不是为我自己的文件获取一些本地、远程和备份文件时,我有类似
#*merge*#30260IgX# #*merge*#48883jX#
这个文件(如果我可以这么说的话)是什么意思,我该如何摆脱它,因为我不确定它是什么......我不想把它提交给我的 repo 协议(protocol),任何建议或变通,如果有人能指出我使用 git merge tool
的适当资源,我将不胜感激。
谢谢!!!
最佳答案
"Merging with “git mergetool” "是一个起点,difftool 和 mergetool 的一般理论在:
"How do I view ‘git diff’ output with visual diff program? "也就是说,对于某些标准差异/merge 工具,它甚至更简单:
"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.
你会发现一个 good tutorial here (在优秀的 gitguru ):
merge 工具
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]
使用“--global
”标志,因此该设置将适用于所有 Git 存储库。
The command line needs to accept the following file variables passed in as parameters:
$LOCAL
– 当前分支版本$REMOTE
– 要 merge 的版本$BASE
– 共同祖先$MERGED
– 将写入结果的文件
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 as false so you will be prompted as to whether the merge conflicts for a file were resolved.
执行有冲突的 merge
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
alt text http://gitguru.com/wp-content/uploads/2009/02/opendiff.png
关于git - 这些文件是什么,我在使用 gitmerge 工具解决冲突时得到的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2851225/