Gitslice
Fast CLI to extract folders or files from GitHub repos using sparse-checkout
Install / Use
/learn @05sanjaykumar/GitsliceREADME
🧩 GitSlice CLI
A CLI tool to extract specific folders or file from GitHub repositories using sparse-checkout.
Designed for speed, simplicity, and developers who don't want to clone massive repos unnecessarily.
🚀 Features
- ⚡️ Extract a specific folder or file from any GitHub repo
- 🔍 Automatically resolves deep nested paths like
/tree/branch/src/utils/ - 🌲 Uses Git sparse-checkout for minimal clone footprint
- 🧹 Cleans up temp files after extraction
- 🔄 Supports both full clone and sparse mode
- 🧠 Intelligent path matching without needing full repo history
📦 Installation
With Go
go install github.com/05sanjaykumar/gitslice@latest
Or clone and build:
git clone https://github.com/05sanjaykumar/gitslice
cd gitslice
go build -o gitslice main.go
🛠️ Usage
Basic Syntax
gitslice <github-folder-or-file-url>
Examples
gitslice https://github.com/supabase/storage/tree/fix/pgboss-on-error-callback/src/auth
gitslice https://github.com/vercel/next.js/tree/canary/packages/next
gitslice https://github.com/05sanjaykumar/Flappy-Bird-OpenCV/blob/main/assets/background-day.png
Output
- Extracts folder/file to the current directory.
- Auto-detects branch and path.
📋 CLI Options
gitslice --help # Show help
gitslice --version # Show version
🧠 How It Works
- Parses the GitHub URL and extracts the owner, repo, branch, and folder or file path.
- Clones the repo in sparse mode without full checkout.
- Sets up sparse-checkout for the specific folder or file.
- Switches to the correct branch and checks out only the required path.
- Moves the folder or file to your working directory and cleans up.
🆚 GitSlice vs Manual Git Commands
With GitSlice ✨
gitslice https://github.com/user/repo/tree/branch/folder
Manual Git Way 😵
git clone --filter=blob:none --sparse https://github.com/user/repo
cd repo
git sparse-checkout init --cone
git sparse-checkout set folder
git checkout branch
cp -r folder ../
cd ..
rm -rf repo
GitSlice does in 1 command what takes 7 manual steps:
- ✅ Parses GitHub URLs automatically
- ✅ Handles branch detection
- ✅ Sets up sparse-checkout configuration
- ✅ Manages temporary directories
- ✅ Cleans up after extraction
- ✅ Works with both folders and individual files
- ✅ Remembers the complex git syntax so you don't have to
Yes, GitSlice requires git to be installed - just like how npm requires Node.js, docker-compose requires Docker, and gh requires git. It's a productivity wrapper that makes complex git operations simple and accessible.
⚠️ Limitations & Edge Cases
Despite its power, GitSlice does have a few known limitations:
-
Branch-specific folders only: If a folder or a file exists only in a non-default branch (e.g., not in
main),GitSlicemight not detect or clone it correctly unless the branch is explicitly specified in the URL. -
Private repositories: GitSlice currently only works with public GitHub repositories. Support for private repos (with authentication) is not yet implemented.
-
Path guessing limitations: The CLI resolves folder or file paths by pattern matching on local clone results. In very complex or dynamically generated repos, edge cases may slip through.
-
Shallow branch detection: We don't fetch the full remote branch list — only the default or specified branch is used for sparse-checkout. If you mistype the branch name or forget it in the URL, cloning will fail.
-
No submodule support (yet): Git submodules aren't handled or fetched. This tool assumes you're targeting standalone folders.
-
GitHub-only: Currently supports only GitHub URLs. Support for GitLab, Bitbucket, etc., is on the roadmap.
🔒 Requirements
- Git installed and available in PATH
- Go 1.18+ (for building from source)
📄 License
MIT © Sanjay Kumar
❤️ Contributing
Pull requests and issues are welcome! If you hit an edge case or repo structure the tool doesn't support, open an issue and let’s improve it together.
Logo Image
Related Skills
node-connect
339.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
xurl
339.3kA CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
frontend-design
83.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
339.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
