0

So I have a git repository. I'm using git 1.7.9 running under Cygwin/Windows 8.

This git repository has this weird behavior so that it thinks that some subdirectories of a certain directory is tracked, but the actual directory containing them is not.

So, I get weirdness like this:

$ git reset --hard
$ git status
#untracked files
foo
$ git clean -fd
removing foo
$ git status
#changes not staged
D foo/bar/whatever.txt

But then, going the other way and adding the files:

$ git add foo
$ git status
# changes not staged
A foo/bar/whatever.txt

And if I commit from there, then it will of course put out crazy conflicts when trying to push.

Occasionally a git reset --hard fixes it, but sometimes not. I've found the best way to get rid of it is to check out a new branch, delete everything in my working copy and run git reset --hard.

Has anyone else ever experienced this weird behavior? I'm using git-tfs, which may mean this is a bug in that, but it is, for the most part, a regular git repository, so I don't think that matters.

Earlz
  • 62,085
  • 98
  • 303
  • 499
  • 2
    What is in your `.gitignore` (and `foo/.gitignore` and `foo/bar/.gitignore` if they exist)? Also, what does `git ls-tree -r HEAD -- foo` tell you about files in `foo` that are being tracked? Are either `foo` or `bar` symbolic links instead of directories? – twalberg Jun 26 '13 at 18:01
  • perhaps (but not likely) a .gitattributes problem with end lines? That's not a git-tfs problem because git-tfs don't touch your workspace folder (especially when you don't call it ;) ) – Philippe Jun 27 '13 at 10:10
  • btw have you tried upgrading to git 1.8? – Bleeding Fingers Jul 01 '13 at 14:24

1 Answers1

0

git clean -fd skips over files that match any of the entries in your .gitignore, which I am assuming is the case. So make sure there is no regex matching foo/bar/whatever.txt in any of your .gitignores.

On more thing make sure that the foo/bar/whatever.txt is not locked, which could be preventing the cleaning.

Bleeding Fingers
  • 6,993
  • 7
  • 46
  • 74