Skip to content

Instantly share code, notes, and snippets.

@fbohz
Forked from cocodrino/download
Created January 10, 2020 19:23
Show Gist options
  • Save fbohz/076eb02c8c9b3809634fd85ced10afab to your computer and use it in GitHub Desktop.
Save fbohz/076eb02c8c9b3809634fd85ced10afab to your computer and use it in GitHub Desktop.
download subfolder github
For other users who just want to download a file/folder from github, simply use:
svn export <repo>/trunk/<folder>
e.g.
svn export https://github.com/lodash/lodash.com/trunk/docs
(yes, that's svn here. apparently in 2016 you still need svn to simply download some github files)
Courtesy: Download a single folder or directory from a GitHub repo
Important - Make sure you update the github URL and replace /tree/master/ with '/trunk/'.
As bash script:
git-download(){
folder=${@/tree\/master/trunk}
folder=${folder/blob\/master/trunk}
svn export $folder
}
source https://stackoverflow.com/questions/600079/how-do-i-clone-a-subdirectory-only-of-a-git-repository
Note This method downloads a folder, does not clone/checkout it. You can't push changes back to the repository. On the other hand - this results in smaller download compared to sparse checkout or shallow checkout.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment