使用 vimdiff 查看所有 `git diffs`
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3713765/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Viewing all `git diffs` with vimdiff
提问by chuckg
I setup git diff
to wrap into vimdiff, using "Git Diff with Vimdiff" as a guide, and it's working as expected unless there are many files with changes.
我设置git diff
包装到 vimdiff 中,使用“ Git Diff with Vimdiff”作为指导,它按预期工作,除非有很多文件有更改。
When there are multiple files with changes and I run git diff
, it opens the first file and, after quitting the first instance of vimdiff, I'm presented with the following message:
当有多个文件有更改并且我运行时git diff
,它打开第一个文件,在退出 vimdiff 的第一个实例后,我看到以下消息:
external diff died, stopping at filename
This is a completely different behavior than I am used to. I had a similar setup in the past with SVN and, when diffing against multiple files, I would review the first file, then write and quit using :wq
and the next file with differences would open up.
这是一种与我习惯的完全不同的行为。过去我对 SVN 进行了类似的设置,当对多个文件进行比较时,我会查看第一个文件,然后写入并退出使用,然后:wq
打开下一个有差异的文件。
This is not the case with Git. I tried :n[ext]
, but doing so does not fill the left window with the original file so that it can be diffed against the modified version.
这不是 Git 的情况。我试过了:n[ext]
,但这样做并没有用原始文件填充左侧窗口,因此可以将其与修改后的版本进行比较。
回答by chuckg
git config --global diff.tool vimdiff
git config --global difftool.prompt false
git config --global alias.d difftool
Typing git d
yields the expected behavior, typing :wq
in vim cycles to the next file in the changeset.
键入会git d
产生预期的行为,:wq
在 vim 循环中键入到变更集中的下一个文件。
回答by czchen
You can try git difftool
, it is designed to do this stuff.
你可以试试git difftool
,它是专为做这些事情而设计的。
First, you need to config diff tool to vimdiff
首先,您需要将 diff 工具配置为 vimdiff
git config diff.tool vimdiff
Then, when you want to diff, just use git difftool
instead of git diff
. It will work as you expect.
然后,当您想区分时,只需使用git difftool
而不是git diff
. 它会按您的预期工作。
回答by Nanhe Kumar
Git accepts kdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, ecmerge,
and opendiff as valid diff tools. You can also set up a custom tool.
git config --global diff.tool vimdiff
git config --global diff.tool kdiff3
git config --global diff.tool meld
git config --global diff.tool xxdiff
git config --global diff.tool emerge
git config --global diff.tool gvimdiff
git config --global diff.tool ecmerge
回答by salty-cat-fish
For people who want to use another diff tool not listed in git, say with nvim
. here is what I ended up using:
对于想要使用未在 git 中列出的其他差异工具的人,请使用nvim
. 这是我最终使用的:
git config --global alias.d difftool -x <tool name>
In my case, I set <tool name>
to nvim -d
and invoke the diff command with
就我而言,我设置<tool name>
到nvim -d
并调用diff命令与
git d <file>