Downloads a subdirectory from a GitHub repository. This tool allows you to fetch only the specific files you need from a larger repository, saving time and bandwidth.
- Selective Download: Downloads only the specified subdirectory from a GitHub repository.
- Cross-Platform: Built with Go, providing binaries for Linux, macOS, and Windows.
- Concurrency: Uses concurrency to speed up the download process.
- SSL Verification: Supports SSL certificate verification (enabled by default).
- GitHub Personal Access Token (PAT): Option to use a PAT for accessing private repositories or to increase rate limits.
Download the pre-built binaries for your operating system from the Releases page. Extract the archive and place the subgit executable in a directory included in your system's PATH.
brew install pranjalya/tap/subgitgo install github.com/pranjalya/subgit@latestsubgit -url <github_url> -root_dir <local_directory> [options]Arguments:
-url: GitHub URL to the subdirectory (e.g.,https://github.com/user/repo/tree/branch/subfolder).-root_dir: Local directory to save the files.
Options:
-no-verify-ssl: Disable SSL certificate verification (not recommended).-pat-token: GitHub Personal Access Token (PAT).
Example:
subgit -url https://github.com/kubernetes/kubernetes/tree/master/staging/src/k8s.io/api -root_dir ./k8s_apiThis command will download the contents of the staging/src/k8s.io/api subdirectory from the kubernetes/kubernetes repository and save them to the ./k8s_api directory.
Using a PAT (Personal Access Token):
To access private repositories or increase rate limits, provide a PAT:
subgit -url https://github.com/private_org/private_repo/tree/main/my_subfolder -root_dir ./my_subfolder -pat-token <your_pat>Disabling SSL Verification (Not Recommended):
subgit -url https://github.com/user/repo/tree/branch/subfolder -root_dir ./my_folder -no-verify-ssl-
Install Go: Make sure you have Go installed (version 1.21 or later).
-
Clone the Repository:
git clone https://github.com/pranjalya/subgit.git cd subgit -
Build the Application:
cd golang go build -o subgit .
This will create an executable named
subgitin thegolangdirectory.
Contributions are welcome! Please feel free to submit pull requests.