我使用 "git diff 来包装到 vimdiff 中“noreferrer">Git Diff with Vimdiff”作为指导,除非有很多文件发生更改,否则它会按预期工作。
当有多个文件发生更改并且我运行 git diff 时,它会打开第一个文件,并且在退出 vimdiff 的第一个实例后,我会看到以下消息:
external diff died, stopping at filename
这是完全不同的行为比我习惯的。我过去在 SVN 上有过类似的设置,当比较多个文件时,我会检查第一个文件,然后使用 :wq
写入并退出,然后会打开下一个有差异的文件。
Git 的情况并非如此。我尝试了 :n[ext]
,但这样做不会用原始文件填充左侧窗口,以便可以将其与修改后的版本进行比较。
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.
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:
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.
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.
发布评论
评论(5)
输入 git difftool 会产生预期的行为。
vim 中的导航命令
:qa
循环到变更集中的下一个文件,而不保存任何内容。别名(示例)
.. 将让您输入 git d 来调用 vimdiff。
高级用例,
:wq
循环到变更集中的下一个文件并保存更改。Typing
git difftool
yields the expected behavior.Navigation commands,
:qa
in vim cycles to the next file in the changeset without saving anything.Aliasing (example)
.. will let you type
git d
to invoke vimdiff.Advanced use-cases,
:wq
in vim cycles to the next file in the changeset with changes saved.你可以尝试 git difftool ,它就是为了做这些事情而设计的。
首先,你需要将 diff 工具配置为 vimdiff
然后,当你想要 diff 时,只需使用 git difftool 代替 git diff 即可。它将按您的预期工作。
You can try
git difftool
, it is designed to do this stuff.First, you need to config diff tool to vimdiff
Then, when you want to diff, just use
git difftool
instead ofgit diff
. It will work as you expect.如果你想永久使用
vimdiff
进行git diff
,可以设置~/.gitconfig
文件:然后就可以使用
git difftool 来比较。
如果你只想暂时使用
vimdiff
,可以每次运行命令:If you want to permanently use
vimdiff
forgit diff
, you can set the~/.gitconfig
file:and then you can use
git difftool
to diff.If you only want to temporarily use
vimdiff
, you can run the command every time:对于想要使用 git 中未列出的其他 diff 工具的人,可以使用 nvim。这是我最终使用的:
在我的例子中,我将
设置为nvim -d
并使用 diff 命令调用For people who want to use another diff tool not listed in git, say with
nvim
. here is what I ended up using:In my case, I set
<tool name>
tonvim -d
and invoke the diff command with