DEV Community

Lemuel Okoli
Lemuel Okoli

Posted on

Git ignoring a directory like it doesn't exist?

You have a cloned repo. There's a directory, call it a/b/c that used to be its own repo, i.e. there was a/b/c/.git/ etc.

Now you want the files managed in the main repo. You don't care about the history in a/b/c, so you deleted the .git dir in a/b/c

But the problem is that git status is ignoring a/b/c completely. You can't git add it. It's as though you'd put the path into .gitignore (You haven't).

You have no idea what the problem was or how it arose (v. annoying), but here is how You can fix it:

git rm --cached a/b/c
git commit -m "removed phantom a/b/c dir"
git add a/b/c
git commit -m "finally able to add a/b/c"

Cheers! 🍻

Top comments (0)