Lenin
Lenin

Reputation: 610

Strategy for multiple projects of git under one project

This question will not be presenting codes. Because I want to know the proper way of using multiple projects inside one project versioned in git.

Let's say I have a master project. And I cloned other dependency projects under subdirectories. What is the standard way to do that?

For example:

Let's say I have cloned Wordpress.

Then I cloned latest OpenSource template under themes folder. And I cloned latest OpenSource plugins under plugins folder.

Each of the sub projects will contain .git folder.

Would I just add them(.git) to .gitignore?

Upvotes: 1

Views: 172

Answers (2)

neevek
neevek

Reputation: 12148

You can use git submodule to manage your subprojects.

Under your master project, execute the following commands to add and clone two subprojects:

git submodule add https://example/project1.git themes/project1
git submodule add https://example/project2.git themes/project2
git submodule update --init

Upvotes: 2

Nevik Rehnel
Nevik Rehnel

Reputation: 52055

If the "subprojects" are dependencies on which you don't usually develop inside of your superproject, and if the subprojects are git repos, a common way to do this is git submodule. Initializing or cloning a submodule, will tell the containing git repo to ignore the contents of that folder, and only remember which revision of the dependency repo you currently have checked out. If the dependencies are not git repos, from a git point of view you would just add them to .gitignore.

Upvotes: 3

Related Questions