Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@cocodrino
Created November 1, 2018 02:48
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cocodrino/ba9481698533f3b8019b511fd283f17f to your computer and use it in GitHub Desktop.
Save cocodrino/ba9481698533f3b8019b511fd283f17f 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