Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
807 views
in Technique[技术] by (71.8m points)

vim - Viewing all `git diffs` 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.

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
git config --global diff.tool vimdiff
git config --global difftool.prompt false

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)

git config --global alias.d difftool

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

Advanced use-cases,

  • 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.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...