简体   繁体   中英

git equivalent to hg -R?

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.

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>.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM