Possible Duplicate:
Is there a way to get to the git root directory in one command?
Sometimes, I'm confused with git thinking that I'm inside a Git working dir, but it's not obvious to me what the top-level working directory (containing .git/
) is. (Probably, that repo was created by a mistake.)
So, how do I find out the top-level Git repo directory if I'm somewhere inside the subdirectories? How do I ask git
to print what it thinks the current top-level working directory is?
Try this:
git rev-parse --show-toplevel