TechTip: How to Git clone subdirectories
The git usage is very widespread among the developers! Through the use of the public or private repository is possible to store code, track versions and share and collaborate with teammate and/or entire communities.
But every repository may contain docs, examples or other files near the needed application. When it’s time to build an application which is composed of files contained in many libraries, the need to “purge” code from unnecessary files become mandatory. In the same way, the continuous pull of dependent libraries could depend on the release of the application.
Git can pull a directory contained in a sub-repository simply enabling “sparseCheckout” config in the root Repository.
1 2 3 4 |
mkdir localrepo cd localrepo git init git remote add -f origin [url repository] |
Then enable “sparseCheckout” option
1 |
git config core.sparseCheckout true |
Every directory is needed in local repo must be indicated “spare-checkout” file under .git/info directory
1 2 |
echo "lib/" >> .git/info/sparse-checkout echo "lib/dummy/" >> .git/info/sparse-checkout |
Next issue a simple git pull.
1 |
git pull origin master |
Enjoy
Un pensiero riguardo “TechTip: How to Git clone subdirectories”
I commenti sono chiusi.