A CLI tool to download specific folders from a git repository.
- 📂 Download specific folders from any Git repository
- 🚀 Fast downloads using sparse checkout or API methods
- 🔒 Support for private repositories
- 🔧 Multiple download methods (API/sparse checkout)
- 🔄 Branch selection support
Using eget
eget dagimg-dot/gitsnip
go install github.com/dagimg-dot/gitsnip/cmd/gitsnip@latest
-
Download the appropriate binary for your platform from the Releases page.
-
Extract the binary:
tar -xzf gitsnip_<os>_<arch>.tar.gz
- Move the binary to a directory in your PATH:
# Option 1: Move to user's local bin (recommended)
mv gitsnip $HOME/.local/bin/
# Option 2: Move to system-wide bin (requires sudo)
sudo mv gitsnip /usr/local/bin/
- Verify installation by opening a new terminal:
gitsnip version
Note: For Option 1, make sure
$HOME/.local/bin
is in your PATH. Addexport PATH="$HOME/.local/bin:$PATH"
to your shell's config file (.bashrc, .zshrc, etc.) if needed.
-
Download the Windows binary (
gitsnip_windows_amd64.zip
) from the Releases page. -
Extract the ZIP file using File Explorer or PowerShell:
Expand-Archive -Path gitsnip_windows_amd64.zip -DestinationPath C:\Program Files\gitsnip
- Add to PATH (Choose one method):
-
Using System Properties:
- Open System Properties (Win + R, type
sysdm.cpl
) - Go to "Advanced" tab → "Environment Variables"
- Under "System variables", find and select "Path"
- Click "Edit" → "New"
- Add
C:\Program Files\gitsnip
- Open System Properties (Win + R, type
-
Using PowerShell (requires admin):
-
$oldPath = [Environment]::GetEnvironmentVariable('Path', 'Machine')
$newPath = $oldPath + ';C:\Program Files\gitsnip'
[Environment]::SetEnvironmentVariable('Path', $newPath, 'Machine')
- Verify installation by opening a new terminal:
gitsnip version
Basic usage:
gitsnip <repo-url> <subdir> <output-dir>
Usage:
gitsnip <repository_url> <folder_path> [output_dir] [flags]
gitsnip [command]
Available Commands:
completion Generate the autocompletion script for the specified shell
help Help about any command
version Print the version information
Flags:
-b, --branch string Repository branch to download from (default "main")
-h, --help help for gitsnip
-m, --method string Download method ('api' or 'sparse') (default "sparse")
-p, --provider string Repository provider ('github', more to come)
-q, --quiet Suppress progress output during download
-t, --token string GitHub API token for private repositories or increased rate limits
- Download a specific folder from a public repository (default method is sparse checkout):
gitsnip https://github.com/user/repo src/components ./my-components
- Download a specific folder from a public repository using the API method:
gitsnip https://github.com/user/repo src/components ./my-components -m api
- Download from a specific branch:
gitsnip https://github.com/user/repo docs ./docs -b develop
- Download from a private repository:
gitsnip https://github.com/user/private-repo config ./config -t YOUR_GITHUB_TOKEN
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- Rate Limit Exceeded: When using the API method, you might hit GitHub's rate limits. Use a GitHub token to increase the limit or use the sparse checkout method. (See Usage)
- Permission Denied: Make sure you have the correct permissions and token for private repositories.