Using git checkout-index to init project from boilerplate repository


As developers, we are always looking for inspiration in other people’s code. Either we learn something totally unfamiliar to us, or we are just in for a trick, but what makes us better developers is the social aspect of coding.

There are a lot of boilerplate repositories that put together several libraries into a starter package for new projects. So how do we use them as efficiently as possible?

Find your favorite boilerplate repository on github. For this example, I am picking the ultimate boilerplate¬†repo only because it has “ultimate” in its name.

So the first step would be to clone it. Business as usual.

$ git clone git@github.com:numerogeek/ultimate-symfony2-boilerplate.git

Old school folks would recursively remove .git folders at this point. But not us. Let’s see what git awesomeness there is in our sleeve:

$ git checkout-index -f -a --prefix=/work/webdev/kickstart/

This will create the /work/webdev/kickstart/ folder and copy all the files there, without the .git items.

Now we can safely navigate to our destination folder

$ cd /work/webdev/kickstart/

and continue with

$ git init

and then add everything to the repo

$ git add .

then just

$ git commit -m "initial setup

We’re ready to go, and not starting from scratch!