Tools: Latest Solved: What In The World Would You Call This…? 2026
Posted on Feb 11
• Originally published at wp.me
TL;DR: A nested .git folder within a Git subdirectory creates ‘phantom submodule’ behavior, preventing the parent repository from tracking individual files and leading to deployment issues. This problem can be resolved by either removing the nested .git folder, formalizing it as a proper Git submodule, or performing a ‘scorched earth’ reset for a guaranteed clean state.
Struggling with a Git subdirectory that won’t track files? Learn why a nested .git folder creates ‘phantom submodule’ behavior and discover three battle-tested methods to fix it, from the quick-and-dirty to the permanent solution.
I’ll never forget it. 3 AM, a Thursday morning, and a ‘critical’ hotfix deployment to production. All the CI checks were green, tests passed, the pipeline glowed with success. We hit the big red button. Ten seconds later, alarms blare. The application on prod-app-01 is crash-looping. The logs scream FileNotFoundException: /etc/app/config/prod-secrets.json. I SSH in, heart pounding, and navigate to the directory. It’s empty. The entire prod-secrets/ directory, which should have been full of config files, was just… gone. After a frantic half-hour, we found the culprit. A junior dev, trying to be helpful, had run git init inside that directory by mistake. Our parent repo saw it, shrugged, and just committed an empty pointer to it instead of the actual files. We’ve all been there, and that phantom commit cost us an hour of downtime and a lot of sweat.
When you see this in your terminal, it’s Git trying to be smart, but in a way that’s incredibly confusing at first glance:
You see modified: src/vendor/some-library, but you can’t add it, you can’t commit it, and Git won’t show you the files inside. This happens because the some-library directory contains its own .git folder. The parent repository sees that .git folder and says, “Whoa, that’s another repository’s territory. I’m not going to track its individual files. I’ll just track which commit that repository is on.”
It’s treating it like a submodule, but without the proper setup in your .gitmodules file. I call it a “Phantom Submodule” or a “Git Nesting Doll”. It’s a repository within a repository, and it’s a common headache.
Depending on your goal and how much you value the history within that nested repo, here are the three paths I usually take, from the quick-and-dirty to the architecturally sound.
This is the most common solution a
Source: Dev.to