Cloning / checking out a certain folder in a GIT repository

Moving from SVN to GIT comes with many advantages. One of the disadvantages I, personaly, have encountered is the fact that you cannot clone a single file or folder in a repository.

Googling to find a decent solution brought me to the following interesting set of commands that actually does that:

From you working copy folder, run: git clone <repo-url> --depth 1 --bare

Now, checkout the subfolder into a new workspace: git --work-tree=/path/to/checkout checkout HEAD -- sub/directory

 

DevOps Engineer

DevOps Group