From: david@lang.hm Date: Wed, 15 Oct 2008 20:17:46 GMT Subject: Re: Untracked working tree files Message-ID: In-Reply-To: On Wed, 15 Oct 2008, Linus Torvalds wrote: > On Wed, 15 Oct 2008, david@lang.hm wrote: >> >> I see it fairly frequently when switching between different branches of a >> project. > > So, at least for any normal switch, assuming file 'a' doesn't exist in the > other branch, you really should have a few different cases: > > - you have a dirty file, and git should say something like > > error: You have local changes to 'file'; cannot switch branches. > > because it refuses to modify the file to match the other branch (which > includes removing it) if it doesn't match the index. > > So this case shouldn't leave anything behind. > > - You have that extra file, but it's not in the index. > > If it's in your current HEAD, we should still notice it with something > like: > > error: Untracked working tree file 'tree' would be removed by merge. > > because now it's untracked (not in the index), but the switching > between branches tries to essentially "apply" the difference between > your current HEAD and the new branch, and finds that the difference > involves removing a file that git isn't tracking. one place that I know I've run into it frequently is in an internal project that I did not properly setup .gitignore and did "git add ." and "git commit -a" to. that projects repository contains the compiled binaries and I frequently get these errors when switching trees. that sounds like the first case. I've seen discussion of a new sequencer functionality, would it allow me to define a .gitignore file and re-create the repository as if that file had existed all along? David Lang > See? > > HOWEVER. > > If you're used to doing "git checkout -f" or "git reset --hard", both of > those checks are just ignored. After all, you asked for a forced switch. > > And at least in the second case, what I think happens is that git won't > remove the file it doesn't know about, so you'll have a "turd" left > around. > > So yes, you can certainly get these kinds of left-overs, but they really > should be only happening if you "force" something. Do you do that often? > > Linus >