git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: how to access working tree from .git dir?

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 7, 2007, 21:44 UTC
Message-ID
<7vhcm62lru.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<1189200421.12525.8.camel@beauty>
Josh England <jjengla@comcast.net> writes:
Show 5 quoted lines
> ... there doesn't seem to be a
> good way to access the top of the working tree from within the GIT_DIR.
> Since I now know that post-receive has a CWD in .git, I could just use
> `pwd`/../ , but I was hoping for a better (read: consistent between
> hooks) solution.

I do not think it is a bad thing for _your_ script to have the knowledge that in _your_ repositories everywhere, the top of the work tree is $GIT_DIR/.. and there is no repository that lacks a work tree. Obviously that would not work for people with bare repositories, but they would not be using _your_ script in their bare repositories, so that is Ok.

You can also configure core.worktree in $GIT_DIR/config and use that from the hook script, I presume, although I haven't done it (and do not see a need to do so) myself yet.

Previous: Josh EnglandNext: Josh England
Message 4 of 9 in “how to access working tree from .git dir?”
  1. Josh EnglandSep 6, 2007
  2. Junio C HamanoSep 7, 2007
  3. Josh EnglandSep 7, 2007
  4. Junio C HamanoSep 7, 2007
  5. Josh EnglandSep 7, 2007
  6. Junio C HamanoSep 7, 2007
  7. Josh EnglandSep 7, 2007
  8. Junio C HamanoSep 7, 2007
  9. Josh EnglandSep 8, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.