PaolaJ.
PaolaJ.

Reputation: 11572

How to add git repo to other repo under subfolder

I have git repo in folder final_app and I have to add new folder app_part which is already git project. When I copied and try git add . or git add --all but it doesn't want to add app_part. How to add files from app_part folder to git repo final_app ?

Upvotes: 1

Views: 45

Answers (1)

VonC
VonC

Reputation: 1328712

You need to not copy it and add that git repo as a submodule:

cd final_app
git submodule add /url/of/repo/app_part/
git add .
git commit -m "Add app_part as submodule"

If you copy it directly, it is just a nested repo which will be ignored by the parent repo.

Adding it as a submodule means adding a gitlink, a special entry in your final_app index, referencing a SHA1 of the app_part repo.

Upvotes: 3

Related Questions