fatal: in unpopulated submodule

Solution 1:

It seems like, you may have removed the .git folder. In that case you can try

 git rm --cached angulartest -f

Solution 2:

git rm --cached . -rf

Stealing from anlijudavid's comment which was the actual answer for me on macOS with zsh. Adding -r based on Richard Collette's comment to this answer.

Solution 3:

The root cause of this error in my case was that I have a subdirectory with its own .git folder inside. When I issued the git add --all command, I got this same error

Here's how I resolved the issue

  1. Remove all .git folder inside the sub directory causing the error
  2. cd to the main directory
  3. git rm --cached sub_directory_name -f
  4. git add --all to add the subdirectory and contents, recursively
  5. git status to verify that the items are added

I almost got a headache with this error but thanks for the previous answers, a combination of those worked for me.

Solution 4:

Here's what I did

  1. Make a copy of the 'submodule' directory somewhere outside of the repository (e.g. your desktop)
  2. Delete the submodule directory from your repo
  3. Commit the repo
  4. Go into the copy you made of your submodule directory, delete .gitignore file and .git directory
  5. Copy the submodule directory back into your repo and commit

This meant I lost the commit history of the submodule but at least it fixed the issue of my files in the submodule not going to git!