laurent
laurent

Reputation: 90736

Why is Git ignoring this directory that is not in .gitignore?

I'm having a strange problem with a directory being ignored even though it's not in .gitignore. To be absolutely sure, I've even deleted .gitignore but that didn't make a difference.

Basically I had a directory "CliClient", which after much refactoring was moved under a different directory. Now I've noticed that when this directory exists, git doesn't see it, but also cannot add it to the index, and cannot delete it.

See below:

Checking that directory exists:

$ ll CliClient/
total 8.0K
drwxr-xr-x  2 4.0K Nov  5 12:31 .
drwxr-xr-x 11 4.0K Nov  5 12:31 ..

Just to test, try to add the directory:

$ git add CliClient/

No, it didn't do it:

$ git status
On branch lerna_migration
Your branch is up to date with 'origin/lerna_migration'.

nothing to commit, working tree clean

So it's probably already added? So delete it:

$ git rm -r CliClient/
fatal: pathspec 'CliClient/' did not match any files

So it's there, not in .gitignore, not in the index, but invisible to git. I've tried many things, including git check-ignore, but that didn't help.

Any idea what could be the reason?

Upvotes: 2

Views: 44

Answers (1)

Mureinik
Mureinik

Reputation: 311063

Git only tracks files. Directories aren't tracked as a "real" entity, but only in the sense of the location of a file. Since the directory is empty there's nothing for git to track there, so the git add call doesn't do anything.

Upvotes: 4

Related Questions