gitsparse-checkout

Checkout subdirectories in Git?


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:

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.


Solution

  • 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.