1

I have a repo for my site I will call mysite. I then have a small django app I made called myApp. I think that myApp is kind of useful so I want other people to be able to download it and include it as a submodule in their apps. But I want to keep the repo inside mysite.

Currently I have a git repo for mysite and inside that I just have another git repo for myapp. I seem to be able to cd into their respective directories and push/pull/edit changes just fine. However, I haven't done anything to set one up as a submodule of the other. Is that something that I need to do? Or is that only if I am using somebody elses module inside mysite and am not going to be making changes to the module?

Chase Roberts
  • 9,082
  • 13
  • 73
  • 131

1 Answers1

1

If you want to switch your nested repo to a submodule repo, all you need to to is:

  • move your nested repo outside the parent repo
  • type:

    git submodule add /remote/url/of/nested/repo
    

With /remote/url/of/nested/repo being the url used when you were pushing to origin from your nested repo.
Complete with:

git submodule update --init

Then add the new gitlink entry which has just been created in the index, commit and push (from the parent repo)

Anyone cloning mysite will be able to do a git submodule update --init and will find your nested repo as submodule, checked out at the last version recorded by the gitlink.

It means your parent repo 'mysite' doesn't include anymore the all nested repo (which would takes some space), but only references said nested repo through a gitlink (very small entry in the index).

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