Skip to content

dagimg-dot/gitsnip

Repository files navigation

gitsnip

A CLI tool to download specific folders from a git repository.

showcase

GitHub release License Downloads

Features

  • 📂 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

Installation

Using eget

eget dagimg-dot/gitsnip

Using Go

go install github.com/dagimg-dot/gitsnip/cmd/gitsnip@latest

Manual Installation

Linux/macOS

  1. Download the appropriate binary for your platform from the Releases page.

  2. Extract the binary:

tar -xzf gitsnip_<os>_<arch>.tar.gz
  1. 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/
  1. Verify installation by opening a new terminal:
gitsnip version

Note: For Option 1, make sure $HOME/.local/bin is in your PATH. Add export PATH="$HOME/.local/bin:$PATH" to your shell's config file (.bashrc, .zshrc, etc.) if needed.

Windows

  1. Download the Windows binary (gitsnip_windows_amd64.zip) from the Releases page.

  2. Extract the ZIP file using File Explorer or PowerShell:

Expand-Archive -Path gitsnip_windows_amd64.zip -DestinationPath C:\Program Files\gitsnip
  1. Add to PATH (Choose one method):
    • Using System Properties:

      1. Open System Properties (Win + R, type sysdm.cpl)
      2. Go to "Advanced" tab → "Environment Variables"
      3. Under "System variables", find and select "Path"
      4. Click "Edit" → "New"
      5. Add C:\Program Files\gitsnip
    • Using PowerShell (requires admin):

$oldPath = [Environment]::GetEnvironmentVariable('Path', 'Machine')
$newPath = $oldPath + ';C:\Program Files\gitsnip'
[Environment]::SetEnvironmentVariable('Path', $newPath, 'Machine')
  1. Verify installation by opening a new terminal:
gitsnip version

Usage

Basic usage:

gitsnip <repo-url> <subdir> <output-dir>

Command Options

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

Examples

  1. Download a specific folder from a public repository (default method is sparse checkout):
gitsnip https://github.com/user/repo src/components ./my-components
  1. Download a specific folder from a public repository using the API method:
gitsnip https://github.com/user/repo src/components ./my-components -m api
  1. Download from a specific branch:
gitsnip https://github.com/user/repo docs ./docs -b develop
  1. Download from a private repository:
gitsnip https://github.com/user/private-repo config ./config -t YOUR_GITHUB_TOKEN

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Troubleshooting

Common Issues

  1. 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)
  2. Permission Denied: Make sure you have the correct permissions and token for private repositories.

About

A CLI tool to download specific folders from a git repository.

Resources

License

Stars

Watchers

Forks

Packages

No packages published