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

Re: GIT_INDEX_FILE relative paths are relative to the work tree

From
Duy Nguyen <pclouds@gmail.com>
Date
Nov 27, 2015, 15:35 UTC
Message-ID
<CACsJy8CzGJxXNy1n+=AzOvPXjp983i_L1tg-_G+9i=qVd7FxmA@mail.gmail.com>
In-Reply-To
<CA+6di1=4GwDg1kksJiKrVtDYSy=Sk=opWcg0=Ekwf0-OoQ2X9g@mail.gmail.com>
On Fri, Nov 27, 2015 at 4:17 PM, Jack O'Connor <oconnor663@gmail.com> wrote:
Show 11 quoted lines
> When I use a relative path in the GIT_INDEX_FILE environment variable,
> git interprets that path relative to the the work tree. This can be
> confusing if my cwd is some subdirectory of my project; in that case
> an index file is created in the project root rather than in my cwd. It
> can also be confusing if I'm using --git-dir and --work-tree, in which
> case the path is interpreted relative to the latter.
>
> Is this behavior intentional? If so, I think it would be worth
> mentioning in the documentation for GIT_INDEX_FILE. But I can't think
> of a case where I would ever want an index file to end up inside my
> work tree.

It would be more intuitive if $GIT_INDEX_FILE is relative to user's current directory, not some random work tree root. And mentioning it as such is not sufficient, we may be able to access the index file without a work tree. This variable is so old that I'm afraid changing its behavior will break stuff, so probably best to document "relative $GIT_INDEX_FILE is undefined behavior"

> This also comes up in http://stackoverflow.com/a/7645492/823869. Using
> absolute paths is a workaround.
-- 
Duy
Previous: Jack O'Connor
Message 2 of 2 in “GIT_INDEX_FILE relative paths are relative to the work tree”
  1. Jack O'ConnorNov 27, 2015
  2. Duy NguyenNov 27, 2015

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.