Explore Courses Blog Tutorials Interview Questions
+4 votes
1 view
in DevOps and Agile by (29.3k points)
edited by

How can I download only a specific folder or directory from a remote Git repo hosted on GitHub?

Say the example GitHub repo lives here:

[email protected]:foobar/Test.git

Its directory structure:




I want to download only the foo folder and not clone the whole Test project.

1 Answer

+4 votes
by (50.2k points)
edited by

Git doesn't support this, but Github does via SVN. If you check out your code with subversion, Github will essentially convert the repo from git to subversion on the backend. There is a popular javascript library  'lodash' i will use this library as an example

1.copy the URL of git repo to your clipboard.

2. Modify this url for subversion:

If you want to download the folder at /docs from the master branch, so you need to append trunk/docs. Full URL is now

3. Download that folder to the command line using:

svn checkout

Note: It may take up to 30 sec to convert large repositories.

For more commands like this please go through the following tutorial that will help you understand the git

Browse Categories