1

I have a newly created local repo in which I created several submodules (based upon subfolders of the local project folder) to enable me to track changes on groups of somewhat unrelated SQL scripts (see https://stackoverflow.com/a/37092715/2958633 for more info). I need to push the entire repo, including the submodules, up to Github and Bitbucket. How can I make this happen?

I may be trying to use submodules in a way that they were not designed to be used, since all of the documentation I have found involve creating submodules from already existing repos. Also, Github nor Bitbucket provide the ability to create empty submodules from within the webpage.

Community
  • 1
  • 1
Michael Sheaver
  • 2,059
  • 5
  • 25
  • 38

1 Answers1

1

The idea of submodules is to create a reference to a remote repo that you include in your main repo as a gitlink SHA1 (special entry in the index) and a .gitmodules url references.

In other words, to add a submodule, you must have reference a remote repo url:

git submodule add -- /url/remote/repo path/to/submodule

So as long as you have pushed your submodules repos, you can simply add, commit and push your main repo.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Two things to add: first, the repos do not yet exist remotely anywhere. Second, I created the submodules locally using "git submodule add mod1 ./mod1". The surprise is that it worked! – Michael Sheaver May 08 '16 at 19:54
  • 1
    @MichaelSheaver That is not how submodules are working. You need to add your submodule by referencing a empty remote repo, then add your file in it, add, commit and push, then go to the parent repo, add, commit and push. – VonC May 08 '16 at 20:01