Robert Hurst
Robert Hurst

Reputation: 9092

Can git submodules have a custom root?

I currently have two projects, a framework and an application. The repository for the framework contains a number of directories that are not useful in the application. I'd like to be able to configure git submodule to only copy the directories I want from my framework repository to the root of my application directory.

Here's what my project directories look like:

Framework

Application

You can see that I want the three directories from the framework repository in the root of my application. can git submodules do this?

Upvotes: 2

Views: 422

Answers (3)

sschuberth
sschuberth

Reputation: 29791

While you can not add arbitrary directories from the framework repository in the root directly, you could make the framework a submodule and use a sparse checkout to only get those parts that you need in your working tree (probably combined with shallow cloning of the submodule).

Upvotes: 1

matthewdaniel
matthewdaniel

Reputation: 1476

Nope. The submodule will clone the entire repository that it points to. Also you cannot delete any folders from a submodule so there is no way to modify it after including it.

Where I work we have found modules to be quite a pain. Every time you redeployment ( depending on your method) you have to go over every submodule and re initial / add it. We tried to use it for our open source additions like tinymce and tcpdf but pitched that method.

Upvotes: 2

Karl Bielefeldt
Karl Bielefeldt

Reputation: 49008

You can do it, but every individual shared folder has to be its own separate submodule. Assuming there are no files at the root level that need to be shared.

Upvotes: 1

Related Questions