Git Directory Diff does not work in my submodule

孤街浪徒 提交于 2019-12-07 08:55:05

问题


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


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!