Reputation: 9275
I have multiple projects in different repositories:
tools
thirdparty
shared
├──Common
├──Exceptions
multimedia
├──VolumeControl
├──VideoRenderer
android
├──Audio
For example, android depends on shared/Common, shared/Exceptions, tools, thirdparty and multimedia/VolumeControl.
I tried:
However, they both checkout or bring-in multimedia folder within the android folder. Instead, I want it like:
android
├──Audio
├──VolumeControl (brought in from multimedia)
How do I accomplish this?
Note: I used to accomplish this using lockexterns in svn.
Upvotes: 1
Views: 1475
Reputation: 5183
I wonder why with git-submodule
it could not be achieved. As I remember, with submodules it is possible to specify the destination directory and hence probably you can do something like this:
$ cd Android
$ git submodule add url/path-to-your-submodule-repo VolumeControl
$ git diff --cached --submodule # OPTIONAL - To verify before commit
$ git commit -m 'added multimedia/VolumeControl as sub-module'
Upvotes: 0
Reputation: 142662
How do I accomplish this?
You can use git filter-branch
and or git subtree split
filter-branch will loop over each commit and then you can checkout only the given files while git subteree split
will be a better option in your case.
Explaining both of the option so you can choose which one you prefer.
filter-branch
# Filter the master branch to your directory and remove empty commits
git filter-branch --prune-empty --subdirectory-filter YOUR_FOLDER_NAME filter_from_branch
This will checkout all your desired files from the given folder to the current directory
subtree split
git subtree
git-subtree
-Merge
subtrees together orsplit
repository into subtrees
git subtree split -P <name-of-folder> -b <name-of-new-branch>
Upvotes: 4