3

I have several projects on my local machine. Created a superproject and added projects in different folders as submodules. All submodules files are copied in superproject. File .gitmodules contains local urls. If I try to push superproject I don't see files of my submodules.

How I can to push superproject with submodules files (instead commits) on github?

P.S. I would like to work separately with projects and publish them as one repo. Thanks for answers!

2 Answers2

3

How I can to push superproject with submodules files (instead commits) on github?

You will need to commit the submodules as folders, not submodules, so you will lose all reference to their repositories.

A submodule is just a commit of a repository. When the repo is cloned, git will attempt to fetch the submodules based on the url in .gitmodules - the content of a submodule doesn't come with the clone action. On GitHub, a submodule is only shown as a commit - it won't contain any of the content.

To keep a submodule's content but stop it being a submodule, follow these steps from this answer. I took the code from that answer rather than just linking to it because it's longer and this is all you need:

git rm --cached submodule_path # delete reference to submodule HEAD (no trailing slash)
git rm .gitmodules             # if you have more than one submodules,
                               # you need to edit this file instead of deleting!
rm -rf submodule_path/.git     # make sure you have backup!!
git add submodule_path         # will add files instead of commit reference
git commit -m "remove submodule"

P.S. I would like to work separately with projects and publish them as one repo. Thanks for answers!

GitHub will helpfully link-up submodules if their repo is on GitHub, i.e. you can click the name or commit to go to that repo's page on GitHub.

Community
  • 1
  • 1
Henry Blyth
  • 1,700
  • 1
  • 15
  • 23
0

Since git 1.8.5 (November 2013):

git submodule deinit yourSubmoduleName
git rm --cached yourSubmodulePath
git add yourSubmodulePath
git commit -m "Remove submodule, add submodule files"

See more here about "How do I remove a Git submodule?".

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250