Skip to content

How can I download a specific folder from a GitHub repo? #23087

Discussion options

You must be logged in to vote

If you are willing to use git to do this, you can do a sparse checkout.

We are going to start by creating an empty git repo locally, and then add the repository we want as a remote. This allows us to easily just checkout the folder we want

mkdir directoryName
cd directoryName
git init
git remote add origin -f repoUrl

After that, we want to add the directory to 

.git/info/sparse-checkout

(this is essentially the opposite of the gitignore file).

Then we can 

git pull origin master

and it should download only the folder you want. 

Obviously, this requires you to use git, but it shouldn’t bee too difficult to automate if it’s something you are doing often.

Replies: 22 comments 11 replies

Comment options

You must be logged in to vote
7 replies
@ecxod
Comment options

@cengit
Comment options

@doubleKari
Comment options

@Qhilm
Comment options

@mmrezasafari
Comment options

Answer selected
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@rulatir
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Kamalabot
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@pizofreude
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Mohsyn
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Repositories The core of version-controlled code storage New User Help ❓ New User help