Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

git-sprig 🌿

Clone a single folder from a GitHub repository — without downloading the whole thing.

https://github.com/{owner}/{repo}/tree/{branch-or-commit}/{path/to/folder}

Why?

Without git-sprig, getting just one folder out of a repository looks like this:

# 1. Clone the entire repository (can be hundreds of MB)
git clone https://github.com/anthropics/anthropic-cookbook.git

# 2. Copy the folder you actually wanted
cp -r anthropic-cookbook/skills ./skills

# 3. Delete the rest
rm -rf anthropic-cookbook

With git-sprig:

git sprig https://github.com/anthropics/anthropic-cookbook/tree/main/skills
# Done. Only the 'skills' folder is in your current directory.

Install

npm install -g git-sprig

Requires Node.js ≥ 14 and Git ≥ 2.25.

Usage

git sprig <github-permalink>

Paste any GitHub URL that points to a folder (the kind you get when browsing a repo's subdirectory):

https://github.com/{owner}/{repo}/tree/{branch-or-commit}/{path/to/folder}

The folder will be downloaded into the current directory. That's it.

Example

# Downloads the 'skills' folder into ./skills
git sprig https://github.com/anthropics/anthropic-cookbook/tree/main/skills

How it works

No GitHub API. No ZIP downloads. Just efficient Git:

  1. Parses the permalink to extract the repo URL, ref, and folder path
  2. Initialises a temporary local repo with git sparse-checkout
  3. Fetches only the target folder with --filter=blob:none --depth=1
  4. Moves the folder contents to the current directory and cleans up .git

License

MIT


Built with AI assistance (GitHub Copilot) for transparency.

About

Clone a single folder from any GitHub repository using its permalink. No full clone, no API, no fuss.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages