# git rev-parse --show-toplevel doesn't work inside git-dir

2 messages from 2013-06-05 to 2013-06-05. Participants: Orgad Shaneh, Jeff King.
Thread: https://gitlist.dev/t/34032

## Orgad Shaneh, 2013-06-05 07:34

Subject: git rev-parse --show-toplevel doesn't work inside git-dir
Message-ID: <CAGHpTB+AOrQfEGRxQ6qwFMFO0eKBMq19e3fUruNedm81o5rJfw@mail.gmail.com>
URL: https://gitlist.dev/e/CAGHpTB%2BAOrQfEGRxQ6qwFMFO0eKBMq19e3fUruNedm81o5rJfw%40mail.gmail.com

```
Running "git rev-parse --show-toplevel" doesn't print anything when it
is run inside .git dir (on all levels)

- Orgad

```

## Jeff King, 2013-06-05 16:17

Subject: Re: git rev-parse --show-toplevel doesn't work inside git-dir
Message-ID: <20130605161754.GD8664@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20130605161754.GD8664%40sigill.intra.peff.net
In-Reply-To: <CAGHpTB+AOrQfEGRxQ6qwFMFO0eKBMq19e3fUruNedm81o5rJfw@mail.gmail.com>

```
On Wed, Jun 05, 2013 at 10:34:11AM +0300, Orgad Shaneh wrote:

> Running "git rev-parse --show-toplevel" doesn't print anything when it
> is run inside .git dir (on all levels)

This is by design. "--show-toplevel" does not print anything when you
do not have a working tree, and you do not have one if you are inside
the .git directory. If you were to do:

  cd .git
  git --work-tree=.. rev-parse --show-toplevel

(or use GIT_WORK_TREE, or set core.worktree, etc), you would get back
the toplevel of the working tree.

-Peff

```
