Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Answer

update of current situation
Source Link
Tobias Knauss
  • 3.6k
  • 1
  • 25
  • 53

Update April 2021: there are a few tools created by the community that can do this for you:

Note: if you're trying to download a large number of files, you may need to provide a token to these tools to avoid rate limiting.


Original (manual) approach: Checking out an individual directory is not supported by Git natively, but GitHub can do this via Subversion (SVN). If you checkout your code with Subversion, GitHub will essentially convert the repository from Git to Subversion on the backend, and then serve up the requested directory.

Update November 2024: The Subversion support has been removed after January 8, 2024: https://github.blog/news-insights/product-news/sunsetting-subversion-support/ . The rest of this answer is outdated and describes the functionality in the past.

Here's how you can use this feature to download a specific folder. I'll use the popular JavaScript library Lodash as an example.

  1. Navigate to the folder you want to download. Let's download /test from master branch.

    GitHub repository URL example

  2. Modify the URL for subversion. Replace tree/master with trunk.

    https://github.com/lodash/lodash/tree/master/test

    https://github.com/lodash/lodash/trunk/test

  3. Download the folder. Go to the command line and grab the folder with SVN.

    svn checkout https://github.com/lodash/lodash/trunk/test
    

You might not see any activity immediately because GitHub takes up to 30 seconds to convert larger repositories, so be patient.

Full URL format explanation:

  • If you're interested in master branch, use trunk instead. So the full path is trunk/foldername
  • If you're interested in foo branch, use branches/foo instead. The full path looks like branches/foo/foldername
  • Pro tip: You can use svn ls to see available tags and branches before downloading if you wish

That's all! GitHub supports more Subversion features as well, including support for committing and pushing changes.

Update April 2021: there are a few tools created by the community that can do this for you:

Note: if you're trying to download a large number of files, you may need to provide a token to these tools to avoid rate limiting.


Original (manual) approach: Checking out an individual directory is not supported by Git natively, but GitHub can do this via Subversion (SVN). If you checkout your code with Subversion, GitHub will essentially convert the repository from Git to Subversion on the backend, and then serve up the requested directory.

Here's how you can use this feature to download a specific folder. I'll use the popular JavaScript library Lodash as an example.

  1. Navigate to the folder you want to download. Let's download /test from master branch.

    GitHub repository URL example

  2. Modify the URL for subversion. Replace tree/master with trunk.

    https://github.com/lodash/lodash/tree/master/test

    https://github.com/lodash/lodash/trunk/test

  3. Download the folder. Go to the command line and grab the folder with SVN.

    svn checkout https://github.com/lodash/lodash/trunk/test
    

You might not see any activity immediately because GitHub takes up to 30 seconds to convert larger repositories, so be patient.

Full URL format explanation:

  • If you're interested in master branch, use trunk instead. So the full path is trunk/foldername
  • If you're interested in foo branch, use branches/foo instead. The full path looks like branches/foo/foldername
  • Pro tip: You can use svn ls to see available tags and branches before downloading if you wish

That's all! GitHub supports more Subversion features as well, including support for committing and pushing changes.

Update April 2021: there are a few tools created by the community that can do this for you:

Note: if you're trying to download a large number of files, you may need to provide a token to these tools to avoid rate limiting.


Original (manual) approach: Checking out an individual directory is not supported by Git natively, but GitHub can do this via Subversion (SVN). If you checkout your code with Subversion, GitHub will essentially convert the repository from Git to Subversion on the backend, and then serve up the requested directory.

Update November 2024: The Subversion support has been removed after January 8, 2024: https://github.blog/news-insights/product-news/sunsetting-subversion-support/ . The rest of this answer is outdated and describes the functionality in the past.

Here's how you can use this feature to download a specific folder. I'll use the popular JavaScript library Lodash as an example.

  1. Navigate to the folder you want to download. Let's download /test from master branch.

    GitHub repository URL example

  2. Modify the URL for subversion. Replace tree/master with trunk.

    https://github.com/lodash/lodash/tree/master/test

    https://github.com/lodash/lodash/trunk/test

  3. Download the folder. Go to the command line and grab the folder with SVN.

    svn checkout https://github.com/lodash/lodash/trunk/test
    

You might not see any activity immediately because GitHub takes up to 30 seconds to convert larger repositories, so be patient.

Full URL format explanation:

  • If you're interested in master branch, use trunk instead. So the full path is trunk/foldername
  • If you're interested in foo branch, use branches/foo instead. The full path looks like branches/foo/foldername
  • Pro tip: You can use svn ls to see available tags and branches before downloading if you wish

That's all! GitHub supports more Subversion features as well, including support for committing and pushing changes.

deleted 12 characters in body
Source Link
Minhas Kamal
  • 22.6k
  • 7
  • 66
  • 67

Update April 2021: there are a few tools created by the community that can do this for you:

Note: if you're trying to download a large number of files, you may need to provide a token to these tools to avoid rate limiting.


Original (manual) approach: Checking out an individual directory is not supported by Git natively, but GitHub can do this via Subversion (SVN). If you checkout your code with Subversion, GitHub will essentially convert the repository from Git to Subversion on the backend, and then serve up the requested directory.

Here's how you can use this feature to download a specific folder. I'll use the popular JavaScript library Lodash as an example.

  1. Navigate to the folder you want to download. Let's download /test from master branch.

    GitHub repository URL example

  2. Modify the URL for subversion. Replace tree/master with trunk.

    https://github.com/lodash/lodash/tree/master/test

    https://github.com/lodash/lodash/trunk/test

  3. Download the folder. Go to the command line and grab the folder with SVN.

    svn checkout https://github.com/lodash/lodash/trunk/test
    

You might not see any activity immediately because GitHub takes up to 30 seconds to convert larger repositories, so be patient.

Full URL format explanation:

  • If you're interested in master branch, use trunk instead. So the full path is trunk/foldername
  • If you're interested in foo branch, use branches/foo instead. The full path looks like branches/foo/foldername
  • Pro tip: You can use svn ls to see available tags and branches before downloading if you wish

That's all! GitHub supports more Subversion features as well, including support for committing and pushing changes.

Update April 2021: there are a few tools created by the community that can do this for you:

Note: if you're trying to download a large number of files, you may need to provide a token to these tools to avoid rate limiting.


Original (manual) approach: Checking out an individual directory is not supported by Git natively, but GitHub can do this via Subversion (SVN). If you checkout your code with Subversion, GitHub will essentially convert the repository from Git to Subversion on the backend, and then serve up the requested directory.

Here's how you can use this feature to download a specific folder. I'll use the popular JavaScript library Lodash as an example.

  1. Navigate to the folder you want to download. Let's download /test from master branch.

    GitHub repository URL example

  2. Modify the URL for subversion. Replace tree/master with trunk.

    https://github.com/lodash/lodash/tree/master/test

    https://github.com/lodash/lodash/trunk/test

  3. Download the folder. Go to the command line and grab the folder with SVN.

    svn checkout https://github.com/lodash/lodash/trunk/test
    

You might not see any activity immediately because GitHub takes up to 30 seconds to convert larger repositories, so be patient.

Full URL format explanation:

  • If you're interested in master branch, use trunk instead. So the full path is trunk/foldername
  • If you're interested in foo branch, use branches/foo instead. The full path looks like branches/foo/foldername
  • Pro tip: You can use svn ls to see available tags and branches before downloading if you wish

That's all! GitHub supports more Subversion features as well, including support for committing and pushing changes.

Update April 2021: there are a few tools created by the community that can do this for you:

Note: if you're trying to download a large number of files, you may need to provide a token to these tools to avoid rate limiting.


Original (manual) approach: Checking out an individual directory is not supported by Git natively, but GitHub can do this via Subversion (SVN). If you checkout your code with Subversion, GitHub will essentially convert the repository from Git to Subversion on the backend, and then serve up the requested directory.

Here's how you can use this feature to download a specific folder. I'll use the popular JavaScript library Lodash as an example.

  1. Navigate to the folder you want to download. Let's download /test from master branch.

    GitHub repository URL example

  2. Modify the URL for subversion. Replace tree/master with trunk.

    https://github.com/lodash/lodash/tree/master/test

    https://github.com/lodash/lodash/trunk/test

  3. Download the folder. Go to the command line and grab the folder with SVN.

    svn checkout https://github.com/lodash/lodash/trunk/test
    

You might not see any activity immediately because GitHub takes up to 30 seconds to convert larger repositories, so be patient.

Full URL format explanation:

  • If you're interested in master branch, use trunk instead. So the full path is trunk/foldername
  • If you're interested in foo branch, use branches/foo instead. The full path looks like branches/foo/foldername
  • Pro tip: You can use svn ls to see available tags and branches before downloading if you wish

That's all! GitHub supports more Subversion features as well, including support for committing and pushing changes.

Third iteration. Properly formatted (as a result the diff looks more extensive than it really is - use view "side-by-side Markdown" to compare) - e.g., four spaces indent is required for list items.
Source Link
Peter Mortensen
  • 31.3k
  • 22
  • 110
  • 134

Update April 2021: there are a few tools created by the community that can do this for you:

Note: if you're trying to download a large number of files, you may need to provide a token to these tools to avoid rate limiting.


Original (manual) approach: Checking out an individual directory is not supported by Git natively, but GitHub can do this via Subversion (SVN). If you checkout your code with Subversion, GitHub will essentially convert the repository from Git to Subversion on the backend, and then serve up the requested directory.

Here's how you can use this feature to download a specific folder. I'll use the popular JavaScript library Lodash as an example.

  1. Navigate to the folder you want to download. Let's download /test from master branch.

    GitHub repository URL example

  2. Modify the URL for subversion. Replace tree/master with trunk.

    https://github.com/lodash/lodash/tree/master/test

    https://github.com/lodash/lodash/trunk/test

  3. Download the folder. Go to the command line and grab the folder with SVN.

    svn checkout https://github.com/lodash/lodash/trunk/test
    
svn checkout https://github.com/lodash/lodash/trunk/test

You might not see any activity immediately because GitHub takes up to 30 seconds to convert larger repositories, so be patient.

Full URL format explanation:

  • If you're interested in master branch, use trunk instead. So the full path is trunk/foldername
  • If you're interested in foo branch, use branches/foo instead. The full path looks like branches/foo/foldername
  • Pro tip: You can use svn ls to see available tags and branches before downloading if you wish

That's all! GitHub supports more Subversion features as well, including support for committing and pushing changes.

Update April 2021: there are a few tools created by the community that can do this for you:

Note: if you're trying to download a large number of files, you may need to provide a token to these tools to avoid rate limiting.


Original (manual) approach: Checking out an individual directory is not supported by Git natively, but GitHub can do this via Subversion (SVN). If you checkout your code with Subversion, GitHub will essentially convert the repository from Git to Subversion on the backend, and then serve up the requested directory.

Here's how you can use this feature to download a specific folder. I'll use the popular JavaScript library Lodash as an example.

  1. Navigate to the folder you want to download. Let's download /test from master branch.

    GitHub repository URL example

  2. Modify the URL for subversion. Replace tree/master with trunk.

    https://github.com/lodash/lodash/tree/master/test

    https://github.com/lodash/lodash/trunk/test

  3. Download the folder. Go to the command line and grab the folder with SVN.

svn checkout https://github.com/lodash/lodash/trunk/test

You might not see any activity immediately because GitHub takes up to 30 seconds to convert larger repositories, so be patient.

Full URL format explanation:

  • If you're interested in master branch, use trunk instead. So the full path is trunk/foldername
  • If you're interested in foo branch, use branches/foo instead. The full path looks like branches/foo/foldername
  • Pro tip: You can use svn ls to see available tags and branches before downloading if you wish

That's all! GitHub supports more Subversion features as well, including support for committing and pushing changes.

Update April 2021: there are a few tools created by the community that can do this for you:

Note: if you're trying to download a large number of files, you may need to provide a token to these tools to avoid rate limiting.


Original (manual) approach: Checking out an individual directory is not supported by Git natively, but GitHub can do this via Subversion (SVN). If you checkout your code with Subversion, GitHub will essentially convert the repository from Git to Subversion on the backend, and then serve up the requested directory.

Here's how you can use this feature to download a specific folder. I'll use the popular JavaScript library Lodash as an example.

  1. Navigate to the folder you want to download. Let's download /test from master branch.

    GitHub repository URL example

  2. Modify the URL for subversion. Replace tree/master with trunk.

    https://github.com/lodash/lodash/tree/master/test

    https://github.com/lodash/lodash/trunk/test

  3. Download the folder. Go to the command line and grab the folder with SVN.

    svn checkout https://github.com/lodash/lodash/trunk/test
    

You might not see any activity immediately because GitHub takes up to 30 seconds to convert larger repositories, so be patient.

Full URL format explanation:

  • If you're interested in master branch, use trunk instead. So the full path is trunk/foldername
  • If you're interested in foo branch, use branches/foo instead. The full path looks like branches/foo/foldername
  • Pro tip: You can use svn ls to see available tags and branches before downloading if you wish

That's all! GitHub supports more Subversion features as well, including support for committing and pushing changes.

Second iteration [<https://en.wikipedia.org/wiki/GitHub> <https://en.wikipedia.org/wiki/Google_Chrome> <https://en.wikipedia.org/wiki/Apache_Subversion> <https://en.wikipedia.org/wiki/JavaScript> <https://en.wiktionary.org/wiki/pro_tip#Noun>]. Expanded.
Source Link
Peter Mortensen
  • 31.3k
  • 22
  • 110
  • 134
Loading
Active reading [<https://en.wikipedia.org/wiki/Git> <https://en.wikipedia.org/wiki/GitHub> <https://en.wikipedia.org/wiki/Lodash>]. Expanded.
Source Link
Peter Mortensen
  • 31.3k
  • 22
  • 110
  • 134
Loading
Rollback to Revision 24 - The edit to add a link was not done by the answer's author so potentially conflicts with their intent
Source Link
Abdul Aziz Barkat
  • 22.3k
  • 9
  • 109
  • 95
Loading
Loading
update link
Source Link
Minhas Kamal
  • 22.6k
  • 7
  • 66
  • 67
Loading
deleted 6 characters in body
Source Link
Loading
improved formatting and added new links
Source Link
nick
  • 20.1k
  • 2
  • 26
  • 31
Loading
edit the link to downgit, as being marked harmful again by google
Source Link
Minhas Kamal
  • 22.6k
  • 7
  • 66
  • 67
Loading
added 12 characters in body
Source Link
Minhas Kamal
  • 22.6k
  • 7
  • 66
  • 67
Loading
deleted 12 characters in body
Source Link
Minhas Kamal
  • 22.6k
  • 7
  • 66
  • 67
Loading
fixed example
Source Link
nick
  • 20.1k
  • 2
  • 26
  • 31
Loading
Updated branch path to be more clear, given my example.
Source Link
nick
  • 20.1k
  • 2
  • 26
  • 31
Loading
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot
Loading
Loading
changed 'branch' to 'branches' in paths in the second bullet in "Full URL format"
Source Link
yair
  • 9.3k
  • 4
  • 36
  • 53
Loading
Rollback to Revision 11
Source Link
nick
  • 20.1k
  • 2
  • 26
  • 31
Loading
deleted 216 characters in body
Source Link
nick
  • 20.1k
  • 2
  • 26
  • 31
Loading
add links to tools that exist now
Source Link
nick
  • 20.1k
  • 2
  • 26
  • 31
Loading
improved formatting and readability even more holy jesus this is amazing
Source Link
nick
  • 20.1k
  • 2
  • 26
  • 31
Loading
Updated for clarity and to stay relevant given current github UI
Source Link
nick
  • 20.1k
  • 2
  • 26
  • 31
Loading
Fixed branch path and rolled back some recent edits of my own (looked too messy)
Source Link
nick
  • 20.1k
  • 2
  • 26
  • 31
Loading
Add instructions on how to checkout folder from specific branch.
Source Link
Loading
1
2

AltStyle によって変換されたページ (->オリジナル) /