In git I want to download a folder from a Github repository and add it to a subdirectory in my repo like so:
repo/folder/subfolder/
repo/folder/subfolder/clonedfolder //cloned folder from git hub
But I get the path directories as well which I don't want.
repo/folder/subfolder/folder/folder1/folder2/clonedfolder
This what I have tried
repo/folder/subfolder$ git init
repo/folder/subfolder$ git remote add -f origin [email protected]:repo/repo.git
repo/folder/subfolder$ git sparse-checkout init
repo/folder/subfolder$ git sparse-checkout set clonedfolder
repo/folder/subfolder$ git sparse-checkout list
- clonedfolder
repo/folder/subfolder$ git pull origin develop
Is this possible in git?
Git isn't geared toward this. Reason being, that whenever you fetch from a repo, your
.git/objectsfolder contains all changes to all files in the repo.*If you have a choice, I'd separate concerns into Git submodules, which are more-or-less independent git repositories linked together using a parent project (with a
.gitmodulesfile).Then you can just use symbolic links to make the directory structure you want.
For example:
After this you can access
childmodule/some-fileas if you were accessing<child repo>/path/to/subfolder/some-file.☥Git will track symbolic links.‡
Footnotes: