git、vimdiff 和 dirdiff [英] git, vimdiff and dirdiff
问题描述
我正在尝试使用 vimdiff+dirdiff.vimVim 中的多个文件版本与 Git 的差异.
I'm trying to use vimdiff+dirdiff.vim to diff inside Vim multiple files versionned with Git.
对于 Mercurial,可以使用 mercurial extdiff 扩展.
For Mercurial, it is possible with mercurial extdiff extension.
我在网上找到的将 Vim 与 Git diff 集成的唯一方法是在单个文件上使用 vimdiff,如 这篇文章.
The only way I found on the web to integrate Vim with Git diff is to use vimdiff on a singe file, as describe in this post.
有人知道vimdiff+dirdiff+git怎么用吗?
Does any one know how to use vimdiff+dirdiff+git?
推荐答案
git 1.7.11 版之前
git-diffall
正是我需要的,非常感谢.在这个 页面 的帮助下,关于 git difftool 和这个 one 关于从命令行运行 vim+dirdiff,我将我的 $HOME/.gitconfig
写为:
Before git version 1.7.11
git-diffall
is what I need, thanks a lot. With help of this page about git difftool and this one about running vim+dirdiff from command line, I wrote my $HOME/.gitconfig
as:
[diff]
tool = default-difftool
[difftool "default-difftool"]
cmd = vim -f '+next' '+execute "DirDiff" argv(0) argv(1)' $LOCAL $REMOTE
[difftool]
prompt = false
将 git-diffall
放入我的 PATH
后,我可以使用以下命令区分工作目录与分支 dev
:
After putting git-diffall
in my PATH
, I can diff for example working directory with branch dev
with:
git diffall dev
--copy-back
也是我需要的,如果我想从 Vim 永久修改工作目录:
The --copy-back
is also what I need if I want to modify the working directory persitantly from Vim:
git diffall --copy-back dev
自 git 版本 1.7.11
自版本 1.7.11, "git difftool" 学习了 "--dir-diff" 选项来简化事情并且不再需要 git-diffall
.
Since git version 1.7.11
Since version 1.7.11, "git difftool" learned the "--dir-diff" option that simplify things and git-diffall
is no longer needed.
.gitconfig
包含:
[diff]
tool = default-difftool
[difftool "default-difftool"]
cmd = vim -f '+next' '+execute "DirDiff" argv(0) argv(1)' $LOCAL $REMOTE '+syntax off'
例如使用分支 dev
区分工作目录是通过以下方式完成的:
And diffing for example working directory with branch dev
is done with:
git difftool -d dev
这篇关于git、vimdiff 和 dirdiff的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!