Subject: Re: git ate my home directory :-(

From: Jonathan Nieder <[email-masked]>
Date: Mon, 25 Mar 2013 15:08:22 -0700

Junio C Hamano wrote:
> Jonathan Nieder <[email-masked]> writes:

>> In git versions including the patch 2cd83d10bb6b (setup: suppress
>> implicit "." work-tree for bare repos, 2013-03-08, currently in "next"
>> but not "master"), you can set GIT_IMPLICIT_WORK_TREE=0 to avoid this
>> behavior.
>
> WAT?

Is that false?

If I understand the history correctly, the ability to set the GIT_DIR
envvar was meant to allow a person to keep their .git directory outside
the worktree.  So you can do:

	git init my-favorite-repo
	cd my-favorite-repo
	...work as usual...

	# cleaning time!
	mv .git ~/my-favorite-repo-metadata.git
	GIT_DIR=$HOME/my-favorite-repo-metadata.git; export GIT_DIR
	... work as usual...

If you want to set GIT_DIR and treat it as a bare repository, the
sane way to do that is simply

	cd ~/my-favorite-bare-repository.git
	... use git as usual ...

But if something (for example relative paths used by your script)
ties your cwd somewhere else, you might really want to do

	GIT_DIR=~/my-favorite-bare-repository.git; export GIT_DIR
	... work as usual ...

and as a side effect of Jeff's patch there is now a mechanism to do
that:

	GIT_IMPLICIT_WORK_TREE=0; export GIT_IMPLICIT_WORK_TREE
	GIT_DIR=~/my-favorite-bare-repository.git; export GIT_DIR
	... work as usual ...

This is of course unsafe because it ties your usage to a specific
version of git.  And the variable is not advertised in the
documentation.