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

GIT_WORK_TREE; a recipe for disaster

From
PSPhillip Susi <phill@thesusis.net>
Date
Mar 3, 2020, 13:53 UTC
Message-ID
<875zflh7dw.fsf@vps.thesusis.net>

I'm using git for windows version 2.25.0.windows.1. Yesterday I was in a bash command line and changed directories to another project. I ran git status and it complained about basically everything being deleted when the files were sitting there just fine. I thought that maybe it is confused since I upgraded git recently and so I ran git checkout -f and git clean -xfd to make sure that the working directory would be restored to a pristine state. I later changed back to the first project directory where I was horrified to see that all of the files from the second project had been checked out, and the changes in that project that I had been working on for a few days had been deleted.

It seems the cause of this is that I had opened git bash from the git gui menu instead of from the windows explorer menu. In previous releases, this cause GIT_DIR to be set ( I believe ), and so that session of git bash was tied to that repoistory even if you changed directories to another repository. I always thought this was rather annoying, but things seem to be worse now that I have upgraded, because git now uses the index and hisotry log etc from the cwd, but compares that index to files elsewhere. This seems like a recipe for disaster. Why does git gui set these environment variables at all, and could it please stop?

Next: Philip Oakley
Message 1 of 2 in “GIT_WORK_TREE; a recipe for disaster”
  1. Phillip SusiMar 3, 2020
  2. Philip OakleyMar 3, 2020

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.