当我键入gitdiff时,我想用我选择的可视化diff工具(Windows上的SourceGear“diffmerge”)查看输出。如何配置git以执行此操作?


当前回答

安装Meld:

 # apt-get install meld

然后选择它作为difftool:

 $ git config --global diff.tool meld

如果要在控制台中运行,请键入:

 $ git difftool

如果要使用图形模式,请键入:

 $ git mergetool

结果将是:

 'git mergetool' will now attempt to use one of the following tools:
 meld opendiff kdiff3 tkdiff xxdiff tortoisemerge gvimdiff diffuse
 diffmerge ecmerge p4merge araxis bc3 codecompare emerge vimdiff
 Merging:
 www/css/style.css
 www/js/controllers.js

 Normal merge conflict for 'www/css/style.css':
   {local}: modified file
   {remote}: modified file
 Hit return to start merge resolution tool (meld):

所以只需按Enter键即可使用meld(默认)。这将打开图形模式。进行神奇的保存并按下以解决合并。这就是全部。

其他回答

对以前的伟大答案的简短总结:

git difftool --tool-help
git config --global diff.tool <chosen tool>
git config --global --add difftool.prompt false

然后通过键入(也可以选择指定文件名)使用它:

git difftool

尝试此解决方案:

$ meld my_project_using_git

Meld了解Git,并提供最近更改的导航。

安装Meld:

 # apt-get install meld

然后选择它作为difftool:

 $ git config --global diff.tool meld

如果要在控制台中运行,请键入:

 $ git difftool

如果要使用图形模式,请键入:

 $ git mergetool

结果将是:

 'git mergetool' will now attempt to use one of the following tools:
 meld opendiff kdiff3 tkdiff xxdiff tortoisemerge gvimdiff diffuse
 diffmerge ecmerge p4merge araxis bc3 codecompare emerge vimdiff
 Merging:
 www/css/style.css
 www/js/controllers.js

 Normal merge conflict for 'www/css/style.css':
   {local}: modified file
   {remote}: modified file
 Hit return to start merge resolution tool (meld):

所以只需按Enter键即可使用meld(默认)。这将打开图形模式。进行神奇的保存并按下以解决合并。这就是全部。

使用新的gitdifftool,只需将其添加到.gitconfig文件中即可:

[diff]
    tool = any-name
[difftool "any-name"]
    cmd = "\"C:/path/to/my/ext/diff.exe\" \"$LOCAL\" \"$REMOTE\""

也可以选择添加:

[difftool]
    prompt = false

还可以查看diffall,这是我编写的一个简单脚本,用于扩展串行打开每个文件的烦人(IMO)默认diff行为。

Windows上的全局.gitconfig位于%USERPROFILE%\.gitconfig中

你可以使用gitdifftool。

例如,如果您有Meld,可以通过以下方式编辑分支master和devel:

git config --global diff.external meld
git difftool master..devel