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

Re: git ate my home directory :-(

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Mar 25, 2013, 22:08 UTC
Message-ID
<20130325220822.GG1414@google.com>
In-Reply-To
<7vfvzjw334.fsf@alter.siamese.dyndns.org>
Junio C Hamano wrote:
> Jonathan Nieder <jrnieder@gmail.com> writes:
Show 6 quoted lines
>> 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.

Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 35 in “git ate my home directory :-(”
  1. Richard WeinbergerMar 25, 2013
  2. Jonathan NiederMar 25, 2013
  3. Junio C HamanoMar 25, 2013
  4. Jonathan NiederMar 25, 2013
  5. Junio C HamanoMar 25, 2013
  6. Junio C HamanoMar 25, 2013
  7. Richard WeinbergerMar 25, 2013
  8. Jonathan NiederMar 25, 2013
  9. Junio C HamanoMar 25, 2013
  10. Richard WeinbergerMar 25, 2013
  11. Jonathan NiederMar 25, 2013
  12. Brandon CaseyMar 25, 2013
  13. Philip OakleyMar 26, 2013
  14. Duy NguyenMar 26, 2013
  15. Jeff KingMar 26, 2013
  16. Junio C HamanoMar 26, 2013
  17. Duy NguyenMar 27, 2013
  18. Philip OakleyMar 26, 2013
  19. Richard WeinbergerMar 26, 2013
  20. Jeff KingMar 26, 2013
  21. Richard WeinbergerMar 26, 2013
  22. demerphqMar 26, 2013
  23. Jeff KingMar 26, 2013
  24. demerphqMar 26, 2013
  25. Jeff KingMar 26, 2013
  26. Junio C HamanoMar 26, 2013
  27. Jeff KingMar 26, 2013
  28. 1/3 environment: set GIT_WORK_TREE when we figure out work treeJeff King, Mar 26, 2013
  29. Jonathan NiederMar 26, 2013
  30. 2/3 setup: warn about implicit worktree with $GIT_DIRJeff King, Mar 26, 2013
  31. Jonathan NiederMar 26, 2013
  32. Jeff KingMar 26, 2013
  33. Jonathan NiederMar 26, 2013
  34. Matthieu MoyMar 27, 2013
  35. 3/3 setup: treat GIT_DIR without GIT_WORK_TREE as a bare repoJeff King, Mar 26, 2013

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.