2

Possible Duplicate:
Is there any way to clone a git repository’s sub-directory only?

Is it possible to clone a repository but some files?

Let's say I don't want to clone the example folder, because anyway I'll delete it after.

Community
  • 1
  • 1
Jonathan de M.
  • 9,721
  • 8
  • 47
  • 72
  • 3
    No. You could stop including example via git ignore OR you could use a hook to auto delete example each time you clone. But genetically there is no easy command for this as it violates the very concept of DVCS – Kansha Feb 05 '13 at 05:42
  • @svnpenn, thanks for the link, I didn't find anything on my previous researchs – Jonathan de M. Feb 05 '13 at 06:01

1 Answers1

7

The short answer - No. Git clone will always clone the complete file structure.

If you want to minimise the amount of data over the network you can use git clone --depth 1.

To achieve what you are asking for:

mkdir repo
cd repo
git init
git remote add -f origin $URL
git config core.sparseCheckout true
echo '$DIRNAME' >> .git/info/sparse-checkout # Do this for every directory you want.
git fetch
git checkout $BRANCH # Typically master

But I think that in your case, it is probably easier to just remove the examples directory.

Zombo
  • 1
  • 62
  • 391
  • 407
Robert
  • 6,855
  • 4
  • 35
  • 43