
π§© 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
Or clone and build:
π οΈ Usage
Basic Syntax
Examples
Output
Extracts folder/file to the current directory.
Auto-detects branch and path.
π CLI Options
π§ 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 β¨
Manual Git Way π΅
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), GitSlice might 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
0 likes Β· 11 views Β· Sep 25, 2025
Developed GitSlice CLI for efficient GitHub repo extraction.
Timeline
Jun 30, 2025 - Jul 7, 2025