Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fatal: in unpopulated submodule

I am quite new to github and I am trying to find a solution to a current problem that I am having. I will go through my process step by step:

First I created a new folder named [project name] Next I used these commands:

    cd [project name]     git clone [remote project from github url] 

So far I have created a folder and cloned a project that my group is working on in github.

Next, I went inside that folder and created an angular project with

    ng new [angulartest] 

This will create all the components of my angular test into the same folder that is the clone of the one from github.

Finally, I pushed the new angular test on github with

    git add [angulartest]     git commit     git push 

What happens is that it only pushes the folder [angulartest] but none of its contents (even though there are contents in it). When I try to pull from its contents, I still just get an empty folder in return.

When I try to enter that folder and add each element of the contents, using these steps:

    cd [angulartest]     git add e2e, src, nodemodules, etc     git commit     git push 

It gives me the following error (even when I try to add each element individually):

fatal: in unpopulated submodule [angulartest]

I was wondering if it was a problem with my git syntax, the angular project, or the way I tried to clone the project. That way, I know which direction I want to be headed when looking for a solution.

like image 366
Junjie Wang Avatar asked Nov 21 '17 00:11

Junjie Wang


People also ask

How to fix fatal error 'submodule name' in Git?

If we cloned from third party repository we got this " fatal: in unpopulated submodule 'submodule name' " error. Also you can remove .git folder manually then you can try to git add I got the same error when I had a subdirectory in my local repo, had deleted the .git to solve different issue, and then tried to add an updated html file to my repo.

Should submodules be initialized first or updated first?

It sounds like you're operating on non-initialized submodules (they're basically missing .git directories), therefore you should initialize them first and update: Check your current outstanding submodules by: git submodule status.

What is a submodule in Git?

Git submodule represents a record in a host git repository pointing to a particular commit in another external repository. The file of the .gitmodule includes meta data on how to map amid the URL of the submodule project and local directory. It is necessary to remove the submodule in case it is not required anymore.

Why am I getting Git add warning when adding a submodule?

Show activity on this post. It seems the git add context is the parent repo ("parent" means the one including the submodule), which triggers the warning. Don't forget that, if this works, you would still have to go back to the parent repo, and git add _site, since the subrepo would have changes.


2 Answers

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

 git rm --cached angulartest -f 
like image 55
Peter Avatar answered Sep 17 '22 18:09

Peter


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.

like image 38
alphablend.dev Avatar answered Sep 17 '22 18:09

alphablend.dev