I am using Git 1.8.4 and Linux (Kubuntu 13.10).
I have a Git repository with submodules. If I ask for directory diff in the main Git module, it works fine. If I do the same in one of the submodules, I get an error:
~/Projects/MAINMODULE/platform/SUBMODULE [master]$ git difftool -tool=meld --dir-diff --cached
fatal: Could not switch to '../../../../platform/': No such file or directory
diff --raw --no-abbrev -z --cached: command returned error: 128
~/Projects/MAINMODULE/platform/SUBMODULE [master]$ cd ..
~/Projects/MAINMODULE/platform [master]$ cd ..
~/Projects/MAINMODULE [master]$ git difftool -tool=meld --dir-diff --cached
// NO PROBLEM, works.
~/Projects/MAINMODULE [master]$ git version
git version 1.8.4
Do you have any idea? May it be a Git Bug?
UPDATE: 1.8.5.3 produces the same output
This workaround works for me:
GIT_WORK_TREE="$(git rev-parse --show-toplevel)" GIT_DIR="$(git rev-parse --git-dir)" git difftool --tool=meld --dir-diff
You can of course put in --cached as per your example.
That's quite a lot to type so you can add the following alias to your ~/.gitconfig
:
[alias]
submeld = !git --work-tree "$(git rev-parse --show-toplevel)" --git-dir "$(git rev-parse --git-dir)" difftool --tool=meld --dir-diff
来源:https://stackoverflow.com/questions/21623155/git-directory-diff-does-not-work-in-my-submodule