Tim Daiber
Tim Daiber

Reputation: 358

How to add sub-modules to github repository

Hello i am looking for a way to add my submodules to my github repo for example

iris

https://github.com/kataras/iris

I tried

git add *
git add .

and then committing and pushing but the folder stay empty (greyed out)

The reason I want to add these submodules is because I want to deploy my application on heroku.

But since the submodules do not get uploaded into my github repo I can not deploy my heroku application since it is missing them from my github repository.

Any ideas on how to add these submodules to my repo would be much appreciated.

Upvotes: 6

Views: 11537

Answers (3)

Yoni Rabinovitch
Yoni Rabinovitch

Reputation: 5261

Are you really sure you need to use git submodule for your use case? I would suggest that you consider git subtree instead. From experience with using both in conjunction with repos deployed to Heroku, I can tell you that git subtree is FAR easier to work with long term.

Upvotes: 2

VonC
VonC

Reputation: 1329322

If you add a nested git repo, you will get a gray folder (gitlink) without being able to retrieve its content.

You need to:

  • make sure there is no pending changes in that nested git repo (everything is committed and pushed to the nested repo remote url)
  • git rm --cached nested_repo_root_folder (no trailing slash)
  • delete completely the nested repo root folder and its content

Then, you can add back that nested repo as a full-fledged submodule:

git submodule add -- /url/nested/repo

Upvotes: 1

bhantol
bhantol

Reputation: 9616

The command to add submodule is

git submodule add <your another repo url>

Refer to git-submodule

Upvotes: 9

Related Questions