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

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

Download a single folder or directory from a GitHub repository

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

Say the example GitHub repository lives here:

[email protected]:foobar/Test.git

Its directory structure:

Test/
├── foo/
│ ├── a.py
│ └── b.py
└── bar/
 ├── c.py
 └── d.py

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

Answer*

Draft saved
Draft discarded
Cancel
33
  • 17
    I modified this to use svn export, as I didn't want a Subversion working copy. Then I added the resulting folder in Git. (I somehow lost a large piece of my directory tree, so I exported from the repo I forked.) Commented Dec 18, 2013 at 18:34
  • 8
    @num3ric- sorry for the late reply, but you should be able to replace "trunk" with "branches/yourbranch" Commented Oct 25, 2014 at 21:49
  • 5
    Still works great as of 2020年6月18日 - downloaded a particular folder in a given branch on Windows 10 using TortoiseSVN -> Export feature (available right clicking on any File Explorer directory), Used this URL: https://github.com/$organization/$repo/branches/$branch/$directory Commented Jun 18, 2020 at 11:11
  • 10
    As of 28th October 2020, if you attempt the method repo/branches/foo_branch/bar_folder you will receive a status 410, feature gone. Commented Oct 28, 2020 at 14:59
  • 16
    GitHub is ending support of SVN on January 8, 2024 github.blog/2023-01-20-sunsetting-subversion-support Commented Jan 27, 2023 at 20:13

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