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

Re: Need to set GIT_WORK_TREE when setting GIT_DIR !?

From
FHFrédéric Heitzmann <frederic.heitzmann@gmail.com>
Date
Mar 11, 2012, 21:13 UTC
Message-ID
<4F5D1590.9050306@gmail.com>
In-Reply-To
<CALeToSV6xx=Vfw8gRbmeKWDzcHFaYvgFhMqx5cwtCYKdASJptw@mail.gmail.com>
Hi all,

My initial mistake was that I unintenionnaly created a bare repo (which is really not what I want to do). If I change that - GIt_DIR=.gita git init --no-bare - everything runs fine.

Lessons learned :

1/ the kind of repo - bare or not bare - that git init creates depends on GIT_DIR. This _is_ documented - I should have read more carefully - but it is surprising for someone not aware of the history of GIT_DIR, GIT_WORK_TREE, and so on. Don't know if it 's worth changing this semantic though. I let more experienced git hackers decide on this.

2/ Calling a git command that needs a working tree (add, status, commit, ...) in a bare repo should probably trigger a more explicit message. Using the current directory if GIT_WORK_TREE is not set would actually hide a potential configuration problem.

Thanks for your help, -- Fred

Previous: Jonathan Nieder
Message 7 of 7 in “Need to set GIT_WORK_TREE when setting GIT_DIR !?”
  1. Frédéric HeitzmannMar 9, 2012
  2. Junio C HamanoMar 9, 2012
  3. Frédéric HeitzmannMar 10, 2012
  4. Nguyen Thai Ngoc DuyMar 10, 2012
  5. Junio C HamanoMar 10, 2012
  6. Jonathan NiederMar 10, 2012
  7. Frédéric HeitzmannMar 11, 2012

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.