git相当于hg -R什么?我想在一个不植根于当前工作目录的父目录的存储库上进行操作。
到目前为止,我有git --git-dir="$a/.git" --work-tree="$a" diff "$a",$agit 存储库目录在哪里。
你所拥有的应该工作。如果您使用的是 git 1.8.5 或更高版本,一个更简单的替代方法是使用-C标志,如下所示:
git -C "$a" diff
Run Code Online (Sandbox Code Playgroud)
从手册页:
-C <path>
Run as if git was started in <path> instead of the current working directory. When multiple -C options are given, each subsequent
non-absolute -C <path> is interpreted relative to the preceding -C <path>.
Run Code Online (Sandbox Code Playgroud)