A lightweight and blazing-fast CLI tool for downloading GitHub directories
gitdig is a command-line utility that lets you download specific directories or entire repositories from GitHub without cloning the whole repository. Perfect for when you need just a portion of a large codebase.
- π Download specific directories or entire repositories
- π Support for recursive subdirectory downloads
- π GitHub authentication to bypass API rate limits
- β‘ Concurrent file operations for maximum performance
- π¨ Colorized terminal output with automatic Windows compatibility detection
- π Progress indicators and download statistics
- π Support for both full GitHub URLs and shorthand notation (
username/repo/path) - π§© Clean and composable command-line interface
go install github.com/liagha/gitdig@latest# Clone the repository
git clone https://github.com/liagha/gitdig.git
# Navigate to the project directory
cd gitdig
# Build the project
go builds -o gitdig
# Optionally install globally
go install# Build current platform, both binary and archive
./build.sh
# Build all platforms, archives only
./build.sh all --format=archive
# Build specific platforms with binaries only
./build.sh linux/amd64 darwin/arm64 --format=binary
# Custom platform combination with both outputs
./build.sh windows/amd64 linux/arm64 --format=allRun gitdig without arguments to launch interactive mode:
gitdigUsage: gitdig [Options]
Options:
-c int
Number of concurrent downloads (default 5)
-i Interactive mode for selecting repositories
-list string
File containing list of repositories to download
-o string
Output directory
-preview
Preview what would be downloaded without downloading
-r Download directories recursively (default true)
-retries int
Number of retries for failed downloads (default 3)
-token string
GitHub API token for authentication
-u string
GitHub repository URL or path (can be specified multiple times)
-update
Only download new or changed files
-user string
GitHub username or organization for interactive repository selection
-v Verbose output
-zip
Create ZIP archive instead of extracting files
gitdig -u https://github.com/golang/go/tree/master/src/encoding/jsonOr using the shorthand format:
gitdig golang/go/src/encoding/jsongitdig -u https://github.com/golang/go/tree/master/src/encoding -r -o ./my-encoding-folderTo avoid GitHub API rate limits, use a personal access token:
gitdig -u https://github.com/golang/go/tree/master/src/encoding/json -t YOUR_GITHUB_TOKENexport GITHUB_TOKEN=YOUR_GITHUB_TOKEN
gitdig golang/go/src/encoding/jsongitdig -u https://github.com/golang/go/tree/master/src/encoding -n 10gitdig -u https://github.com/golang/go/tree/master/src/encoding -vFor frequent use or downloading from private repositories, it's recommended to use GitHub authentication:
- Create a Personal Access Token on GitHub
- Use it with the
-tflag or set it as an environment variable
gitdig -u https://github.com/golang/go/tree/master/src/encoding \
-r \
-o ./golang-encoding \
-n 8 \
-t YOUR_GITHUB_TOKEN \
-vThis will:
- Download the
encodingdirectory from the Go repository - Download all subdirectories recursively
- Save to
./golang-encoding - Use 8 concurrent downloads
- Use your GitHub token for authentication
- Show verbose output during the process
- For large directories, increase concurrency (
-n) for faster downloads - Set your GitHub token as an environment variable to avoid exposing it in your command history
- Use the recursive flag (
-r) with caution on large repositories
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Built with β€οΈ by liagha