使用 vimdiff 查看所有 `git diffs` [英] Viewing all `git diffs` with vimdiff

查看:29
本文介绍了使用 vimdiff 查看所有 `git diffs`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Git Diff with Vimdiff" 作为指南,它按预期工作,除非有很多文件发生了变化.

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 的第一个实例后,看到以下消息:

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

这与我习惯的行为完全不同.过去我对 SVN 进行了类似的设置,当对多个文件进行比较时,我会查看第一个文件,然后使用 :wq 编写并退出,然后打开下一个有差异的文件.

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.

这不是 Git 的情况.我尝试了 :n[ext],但这样做不会用原始文件填充左侧窗口,因此可以将其与修改后的版本进行比较.

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 config --global diff.tool vimdiff
git config --global difftool.prompt false

输入 git difftool 会产生预期的行为.

Typing git difftool yields the expected behavior.

  • :qa 在 vi​​m 中循环到变更集中的下一个文件,不保存任何内容.
  • :qa in vim cycles to the next file in the changeset without saving anything.
git config --global alias.d difftool

.. 会让你输入 git d 来调用 vimdiff.

.. will let you type git d to invoke vimdiff.

  • 默认情况下,git 使用 -R 选项调用 vimdiff.您可以使用 git config --global difftool.vimdiff.cmd 'vimdiff "$LOCAL" 覆盖它.$远程".这将以可写模式打开 vimdiff,允许在 diff 时进行编辑.
  • :wq 在 vi​​m 中循环到更改集中保存更改的下一个文件.
  • By default, git calls vimdiff with the -R option. You can override it with git config --global difftool.vimdiff.cmd 'vimdiff "$LOCAL" "$REMOTE"'. That will open vimdiff in writeable mode which allows edits while diffing.
  • :wq in vim cycles to the next file in the changeset with changes saved.

这篇关于使用 vimdiff 查看所有 `git diffs`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆