Skip to content

Instantly share code, notes, and snippets.

@radavis
Created October 3, 2017 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save radavis/d0c96f00f07bd0b7e8c47f2f327be152 to your computer and use it in GitHub Desktop.
Save radavis/d0c96f00f07bd0b7e8c47f2f327be152 to your computer and use it in GitHub Desktop.

Clone a folder from a GitHub repo

Create an access token

Providing an access token allows you to avoid a user/password authentication prompt.

https://username:GITHUB_ACCESS_TOKEN@github.com/username/repo.git

Command sequence

git init
git remote add origin https://username:GITHUB_ACCESS_TOKEN@github.com/username/repo.git
git config core.sparseCheckout true
echo "path/to/folder/within/repo" >> .git/info/sparse-checkout
git pull origin master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment