Archive or clone specific files/directories with git (specifically github)

I’m trying to make a customizer similar to the one used by Twitter for their Bootstrap framework (http://twitter.github.com/bootstrap/customize.html). I have a github repo that I need to be able to specify certain files and directories to download as a zip.

I’ve looked into possible solutions, and have a few ideas on how I can accomplish this. But I’d like some feedback.

git archive will not work because the repo is on github and apparently they do not allow this. Also, I’ve not been able to find a way to specify files to include or exclude in the command itself.

My first thought was to create a script that clones the repo into a temporary directory and then delete the files I don’t want in the zip (including git files). The problem with this is I’d always be downloading everything — even the stuff I don’t want in the zip.

My other idea is to have a list of files to download and a script that loops through that list to get the files from raw.github.com.

What is the best way to do this? Does anyone know how Twitter accomplishes this for Bootstrap?

EDIT: Just to be clear, I’m not trying to create my own custom builder for Bootstrap; I have my own, unrelated project on github.

  • How to clone git repository from its zip
  • Subversion diff for zipped xml file
  • How to zip git branch?
  • Is there any easy way to .zip up my source code with Visual Studio 2013?
  • Does git smartly handle a zip archive in which only one of the files changes regularly?
  • Is there an opposite command to git archive for importing zip files
  • How do I download the Gson library?
  • Why does Zipping the same content twice gives two files with different SHA1?
  • One Solution collect form web for “Archive or clone specific files/directories with git (specifically github)”

    I contacted Jacob Thorton, one of the developers of Bootstrap, and he pointed me in the direction of the GitHub repo for their Heroku-hosted server-side process that creates the ZIP. (See Ivan Zuzak’s comment in the question.)

    For anyone who stumbles upon this question, you can find it here: https://github.com/twitter/bootstrap-server

    They are doing what I (and Ivan) suspected: getting the raw files from http://raw.github.com and creating the ZIP from that.

    Git Baby is a git and github fan, let's start git clone.