git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* GIT_WORK_TREE; a recipe for disaster
@ 2020-03-03 13:53 Phillip Susi
  2020-03-03 14:22 ` Philip Oakley
  0 siblings, 1 reply; 2+ messages in thread
From: Phillip Susi @ 2020-03-03 13:53 UTC (permalink / raw)
  To: git

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?


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: GIT_WORK_TREE; a recipe for disaster
  2020-03-03 13:53 GIT_WORK_TREE; a recipe for disaster Phillip Susi
@ 2020-03-03 14:22 ` Philip Oakley
  0 siblings, 0 replies; 2+ messages in thread
From: Philip Oakley @ 2020-03-03 14:22 UTC (permalink / raw)
  To: Phillip Susi, git, Pratyush Yadav

On 03/03/2020 13:53, Phillip Susi wrote:
> 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?
>
Probably worth including Pratyush Yadav for the git-gui maintenance aspect.
--
Philip

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-03 14:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-03 13:53 GIT_WORK_TREE; a recipe for disaster Phillip Susi
2020-03-03 14:22 ` Philip Oakley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).