Git ignoring a directory like it doesn't exist?

okolilemuel

Lemuel Okoli

Posted on March 17, 2020

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! 🍻

💖 💪 🙅 🚩
okolilemuel
Lemuel Okoli

Posted on March 17, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related