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

Re: behaviour of git diff, GIT_DIR & checked out tree

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 24, 2007, 18:31 UTC
Message-ID
<7vwsufap9z.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<e1dab3980709241009q71f9a40r1f8b551b417f7475@mail.gmail.com>
"David Tweed" <david.tweed@gmail.com> writes:
> ... I'm just asking if there's a way to say
> "the `working dir' associated with this git dir" explicitly (in the same
> way I can use `HEAD' to refer to the topmost commit on the
> current branch) when you're not somewhere within the 'working dir'.

Not for "git diff <one-tree>" which is a way to diff the _part_ of work tree you are _currently in_ with the given tree, nor for "git diff" which is to do the same with the index. With these commands (and others that error out when you run without GIT_DIR outside the work tree), you are really expected to be _in_ the subdirectory you are interested in.

GIT_WORK_TREE is somewhat related but is a different issue, by the way. It is to let you say where the top level of the work tree is. It does not change the fact that the way for you to express which subdirectory in the work tree you are interested in to work tree commands is by your $PWD relative to the top of the work tree.

Previous: David Tweed
Message 6 of 6 in “behaviour of git diff, GIT_DIR & checked out tree”
  1. David TweedSep 24, 2007
  2. Johannes SchindelinSep 24, 2007
  3. David TweedSep 24, 2007
  4. Junio C HamanoSep 24, 2007
  5. David TweedSep 24, 2007
  6. Junio C HamanoSep 24, 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.