Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make "git difftool --dir-diff" working with vim

I am happy working with git difftool --dir-diff with beyond compare to show overall diff across directories and files and navigate through them.

However when it comes to vimdiff, seems it do not support dir diff from git. A git alias I created is as the following

    dirdiff = difftool --ignore-submodules --tool=vimdiff --dir-diff --no-symlinks

After I do things like git dirdiff HEAD~1 HEAD, it list my 2 directories on left and right with vim built in netrw file browser. However, press enter on any of them don't make folder expanded on both sides, not to mention open a file with side by side diff.

vimdiff works fine for showing single file diff in visual mode, is there a way to make it also works for --dir-diff?

like image 957
Eric Sun Avatar asked Aug 31 '26 00:08

Eric Sun


1 Answers

I find a solution from another stackoverflow thread. The answer is provided by @user744629. Following his suggestion

  • install vim dirdiff
  • add the following configuration in .gitconfig
[alias]
    dirdiff = difftool --ignore-submodules --dir-diff --no-symlinks --tool=vimdirdiff

[difftool "vimdirdiff"]
    cmd = vim -f '+next' '+execute \"DirDiff\" argv(0) argv(1)' $LOCAL $REMOTE

After that you can use git dirdiff HEAD HEAD~1 to view side by side diff.

like image 97
Eric Sun Avatar answered Sep 02 '26 14:09

Eric Sun



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!