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