git, vimdiff and dirdiff

后端 未结 4 2098
没有蜡笔的小新
没有蜡笔的小新 2020-12-14 08:17

I\'m trying to use vimdiff+dirdiff.vim to diff inside Vim multiple files versionned with Git.

For Mercurial, it is possible with mercurial extdiff extension.

4条回答
  •  醉酒成梦
    2020-12-14 09:13

    Before git version 1.7.11

    git-diffall is what I need, thanks a lot. With help of this page about git difftool and this one about running vim+dirdiff from command line, I wrote my $HOME/.gitconfig as:

    [diff]
      tool = default-difftool
    
    [difftool "default-difftool"]
      cmd = vim -f '+next' '+execute \"DirDiff\" argv(0) argv(1)' $LOCAL $REMOTE
    
    [difftool]
      prompt = false
    

    After putting git-diffall in my PATH, I can diff for example working directory with branch dev with:

    git diffall dev
    

    The --copy-back is also what I need if I want to modify the working directory persitantly from Vim:

    git diffall --copy-back dev
    

    Since git version 1.7.11

    Since version 1.7.11, "git difftool" learned the "--dir-diff" option that simplify things and git-diffall is no longer needed.

    .gitconfig contains:

    [diff]
      tool = default-difftool
    [difftool "default-difftool"]
      cmd = vim -f '+next' '+execute \"DirDiff\" argv(0) argv(1)' $LOCAL $REMOTE '+syntax off'
    

    And diffing for example working directory with branch dev is done with:

    git difftool -d dev
    

提交回复
热议问题