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

Re: "GIT_INDEX_FILE" environment variable

From
Linus Torvalds <torvalds@osdl.org>
Date
Apr 21, 2005, 18:37 UTC
Message-ID
<Pine.LNX.4.58.0504211130480.2344@ppc970.osdl.org>
In-Reply-To
<Pine.LNX.4.58.0504211100330.2344@ppc970.osdl.org>
On Thu, 21 Apr 2005, Linus Torvalds wrote:
> 
> You can also use it to test merges without screwing up your old index file 
> in case something goes wrong.

Btw, if it wasn't obvious, for the merge thing to work you need to first copy the old index file _or_ generate a new temporary index file first, so that doing the three-way merge has a previous index file to work with. Ie it would look something like

	cp .git/index .tmp-index
	GIT_INDEX_FILE=.tmp-index read-tree -m $orig $branch1 $branch2

but this same approach can also be used to merge things _without_ actually having any specific version checked out, in which case it would just be

	GIT_INDEX_FILE=.tmp-index read-tree $orig
	GIT_INDEX_FILE=.tmp-index read-tree -m $orig $branch1 $branch2

which allows you to create a merged index file that is totally independent on whatever (if anything) you happen to be working on right now.

Together with a SHA1_FILE_DIRECTORY, it allows you to do merges entirely outside any real git tree, and without any other setup. That's quite nice for the case where your actual working tree may be dirty, and you don't want to mess around in it.

			Linus
Previous: Davide LibenziNext: Junio C Hamano
Message 3 of 14 in “"GIT_INDEX_FILE" environment variable”
  1. Linus TorvaldsApr 21, 2005
  2. Davide LibenziApr 21, 2005
  3. Linus TorvaldsApr 21, 2005
  4. Junio C HamanoApr 22, 2005
  5. Linus TorvaldsApr 22, 2005
  6. Junio C HamanoApr 22, 2005
  7. Petr BaudisApr 22, 2005
  8. Linus TorvaldsApr 22, 2005
  9. Junio C HamanoApr 22, 2005
  10. Linus TorvaldsApr 22, 2005
  11. Junio C HamanoApr 22, 2005
  12. Petr BaudisApr 22, 2005
  13. Linus TorvaldsApr 22, 2005
  14. Zach WelchApr 22, 2005

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.