checkout to other directory (Re: [PATCH 3/3] setup: always honor GIT_WORK_TREE and core.worktree)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Maaartin wrote:

> Actually I did mostly something like
>
> git --work-tree /tmp/somewhere checkout somebranch -- .
>   && winmerge . /tmp/somewhere
>
> at root of my normal work tree as a poor man's replacement for
>
> git difftool somebranch
>
> This is probably no good idea as it mixes up the index.

Right.  I think the simplest (and usual) method is something like

	rm -fr /tmp/somewhere &&
	mkdir -p /tmp/somewhere &&
	git archive somebranch | (cd /tmp/somewhere && tar -xf -)

But suppose that the tracked tree is very big, so that re-creating
/tmp/somewhere each time is expensive.  Then you can do

	(
		GIT_DIR=$(pwd)/.git &&
		GIT_INDEX_FILE=$(pwd)/.git/somewhere-index &&
		export GIT_DIR GIT_INDEX_FILE &&

		cd /tmp/somewhere &&
		git update-index --refresh -q &&
		git read-tree --reset -m -u somebranch
	)

The state of /tmp/somewhere is remembered in the somewhere-index file.

In practice, I tend to use something closer to the following:

	sh /usr/share/doc/git/contrib/git-new-workdir repo /tmp/somewhere &&
	(
		cd /tmp/somewhere &&
		git checkout somebranch^0
	)

See [1] for caveats and future directions.

[1] http://thread.gmane.org/gmane.comp.version-control.git/150559
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]