//TODO en Français
SVN externals is a really nice feature I used a lot. Switching to git I was really missing it. Of course there is git-submodule but it’s not the same. Now, with version 1.7 git supports so called sparse checkouts which allow you to only include specific sub directories of a repository in your project. You still need to clone the whole repository, but afterwards you can tell git to only show the specified sub directories.
Here is how it works:
- clone the other repository (in my case, for a Rails app, I did it in vendor/plugins/)
git clone <repository_url> <directory>
- cd to <directory>
cd <directory>
- enable sparsecheckout
git config core.sparsecheckout true
- add directories you want to have in your checkout to
.git/info/sparse-checkout
, e.g.echo app/models/ > .git/info/sparse-checkout echo lib/ >> .git/info/sparse-checkout
- run read-tree
git read-tree -m -u HEAD
ls
now showsapp lib
Forgot a directory you wanted to include? Just repeat step 4 and 5.
Aucun commentaire:
Enregistrer un commentaire