3

i need something like git submodules, but the submodule have to be a directory of another project, rather than the entire project.

For example

The Submodule has:

somedir files dirs someotherdir files dirs thewanteddir files dir 

I want to link thewanteddir with another project

Is there anything that works like that?

2 Answers 2

1

If somedir, someotherdir and thewanteddir are already part of one repo, then you cannot directly see just thewanteddir (At best you would the 'theSubmoduleRootDir/thewanteddir' anyway)
(And shallow clone submodules wouldn't isolate just one subdirectory)

The cleanest solution (but not the easiest one) would be to split that submodule repo in two, and make thewanteddir its own repo (which you can then add as a submodule)

Sign up to request clarification or add additional context in comments.

1 Comment

Note: partial clone by filepath is not possible with Git: see stackoverflow.com/questions/2586824/…
1

You could use git-subtree to split off a branch that just has the history of the thewanteddir subdirectory, and then set that commit to be the submodule version. (You'd need to keep using git-subtree to update the submodule, and merge back in changes.)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.