tags:

views:

19

answers:

1

Hi all,

Assuming I am somewhere in a repository managed by git, which is based at some path. I.e.:

/home/whatever/username/MyRepository/a/b/c

where everything under

/home/whatever/username/MyRepository

is under git control.

Is there a git command I can run from some arbitrary location under the managed path which returns the base path (in this case

/home/whatever/username/MyRepository

)? I could reverse search through the directory structure, and wait to find the .git directory, but that seems exceptionally hackish.

Thanks!

+1  A: 

This:

git rev-parse --show-toplevel
Charles Bailey
This doesn't seem to work for me. (git version 1.6.4.msysgit.0) Is there something to this?
AndyL
`--show-toplevel` is >= 1.7.0. If you can't upgrade you should still have `git rev-parse --show-cdup` and `git rev-parse --show-prefix` either of which can give you what you need perhaps with a bit of scripting.
Charles Bailey
Perfect, thank you.
Greybadger