I add new folder (actually I cloned it from another repo, and forgot that), then I did some changes there. Additionally I did a lot of changes in another places, when I tried to do git add

# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#   (commit or discard the untracked or modified content in submodules)
#   modified:   protected/ext/SpecificFolder (modified content)

Then I remember that maybe there was .git folder (because previous I did git clone there). I went to that folder and remove non needed files (folders) and .git folder too. I checked git status, nothing strange. Then commit and checkout to another branch and suddenly I figure out that this folder was not added to last commit. Actually folder was added but files inside was ignored. Now even when I'm trying to do git add for that folder nothing happenning and git status do not show any changes :(

What can I do ?

  • 6
    In case anyone else ends up on this page with the problem I faced: I wasn't able to add files in a sub-folder to Git. Later I found that that sub-folder had its own .git repository and files were getting added to that repository instead of the repository in the main folder. Even in the Git GUI, that sub-folder appeared as a file instead of as a folder.
    – Nav
    Jul 18 '14 at 3:26
  • This exact problem has happened to me and it's very frustrating. There is an empty folder on GitHub, I didn't even know that was possible. May 26 '20 at 20:09

Git doesn't track directories; but just the files within them.

It sounds like you might have an ignore pattern that is causing add to do nothing. You can see ignored files with git status --ignored; they can then be tracked with git add --force protected/ext/SpecificFolder

  • 1
    No it's not presen in git status --ignored, somehow I'm thinking it is connected with submodule Apr 16 '13 at 18:36
  • 3
    This command was a life-saver. Without it, I would've never figured out which directory was ignored. Jun 5 '15 at 15:25
  • 1
    wow..... I felt totally stupid reading this fact after using git for some time now ^^
    – XandruCea
    Aug 11 '17 at 20:04
  • 1
    Aha, finally. This was my problem. I had copied .gitignore from parent and into submodules. I was ignoring 'config/' and later I created a directory under source dir named config. Could not add of cource. Problem solved now thank you :-)
    – Avec
    May 16 '18 at 8:13
  • cool ,save my time Apr 24 '20 at 9:29

Git doesn't track EMPTY directories. If you have a project w/ multiple layers of subdirectories, git does in fact track the directories w/ files in them. If it didn't, then it would be one flat repository of files.

  • Wow this is such a simple thing but damn. I read this and went "oh my God that's exactly it" Aug 3 '18 at 14:15

I happened to do exactly what this user did: Add an existing git repository inside another one.

The symptom was that git recognised that directory as a file, and thus was unable to add the directory's files.

To solve that question, I deleted the .git folder in the folder, moved that folder in another directory, cleared the index, removed the directory where in my repo, and then I was able to add the directory properly.

The moral of this is: don't add a repository inside another one.

  • 13
    It can also be fixed by running git rm --cached path_to_submodule Jan 15 '16 at 11:21
  • VictorMarchuk this solved my problem after I deleted the .git directory
    – Alessi 42
    Mar 4 '20 at 21:54
  • @VictorMarchuk This solved my problem!! May 26 '20 at 20:30

There is a better answer here: .gitkeep usage

TL;DR, add a .gitkeep file to your empty directory


Try adding a file in that directory.

$ git add my-dir/index.html

If you see a output like the below:

The following paths are ignored by one of your .gitignore files:
Use -f if you really want to add them.
fatal: no files added

There's a rule in one of your gitignores that prevent you from adding that directory.


I found similar side-effects after trying to convert what used to be a submodule into a normal subfolder.

Re-adding the folder I was attempting to convert seemed to work, but it turns out that the files inside it were not actually added.

Trying to specifically add a file inside it gave me a better warning

git add sites/all/modules/contrib/transclusion/transclusion.module 
fatal: Pathspec 'sites/all/modules/contrib/transclusion/transclusion.module' is in submodule 'sites/all/modules/contrib/transclusion'
  • so it was related to the way I had manually tried to remove the old submodule, as there was no well-documented process for doing it properly. - I had just deleted it from .gitmodules. Other stuff was actually necessary to eraticate the shadows of the submodule.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.