Reputation: 118470
What is the git equivalent to hg -R
? I want to operate on a repository that isn't rooted in a parent directory of the current working directory.
So far I have git --git-dir="$a/.git" --work-tree="$a" diff "$a"
, where $a
is the git repository directory.
Upvotes: 2
Views: 185
Reputation: 37167
What you have should work. If you're using git 1.8.5 or higher, a simpler alternative is to use the -C
flag, like this:
git -C "$a" diff
From the man page:
-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>.
Upvotes: 5