Search code examples
gitgithubgit-submodules

GitHub submodule is empty in the cloud/server


I am working on building a custom OS using buildroot. The working tree of my project is as follows final-project-DeekshithPatil (Main git repository) \

 ---> base_external \
 ---> builroot (git cloned)\
 ---> README.md

The link to my repository is here, https://github.com/cu-ecen-aeld/final-project-DeekshithPatil

I have modified the buildroot directory as necessary and pushed to the cloud (gitHub). On the cloud I see that the buildroot repository appears as a submodule as needed. However, it is empty.

How do I solve this issue?

NOTE: Within buildroot directory, I have tried adding git remote add origin: [https://github.com/cu-ecen-aeld/final-project-DeekshithPatil][1] And then tried pushing using git push. This is the error I get:

fatal: You are not currently on a branch. To push the history leading to the current (detached HEAD) state now, use

git push origin HEAD:


Solution

  • So, I was able to solve this by adding a .gitmodules file as pointed by @phd in his comment.

    I first created a file in the root of the repo as follows,

    touch .gitmodules
    

    Next I added the following lines to the file .gitmodules,

    [submodule "buildroot"]
     path = buildroot
     url = https://github.com/buildroot/buildroot
     branch = 2020.02.2
    

    After this I was able to add, commit and push .gitmodules to gitHub. The buildroot folder now points to the url mentioned in .gitmodules.