Checkout subdirectories in Git?

Annika Backstrom picture Annika Backstrom · Oct 7, 2008 · Viewed 132.6k times · Source

Is it possible to check out subdirectories of a repository in Git?

Imagine I am setting up a new WordPress installation. I will create two new directories for my plugin and theme customization:

  • wordpress/wp-content/plugins/myplugins/
  • wordpress/wp-content/themes/mytheme/

I want to maintain these directories via Git. In Subversion, I would accomplish this by having trunk/myplugins/ and trunk/mytheme/ directories and checking out subdirectories. Does Git have a way to accomplish the same task using a single repository?

I could just be missing the boat on some Git paradigm, as a long time SVN user with little exposure to Git.

Edit: Multiple branches storing different content is an interesting way to handle this.

Answer

Collin Anderson picture Collin Anderson · Feb 20, 2010

Sparse checkouts are now in Git 1.7.

Also see the question “Is it possible to do a sparse checkout without checking out the whole repository first?”.

Note that sparse checkouts still require you to download the whole repository, even though some of the files Git downloads won't end up in your working tree.