Skip to main content

Download single files or folders from a github repository without cloning its entire contents.

Project description

ghget logo

PyPI version PyPI - Downloads Build Status Code Style pre-commit Contributor Covenant GitHub

Description

Download single files or directories from a GitHub repository without cloning its entire contents.

Features

  • No need to manually create a raw GitHub url for individual files, just provide the web url.
  • Recursively download entire directories.
  • Download from private repos using your GitHub token.
  • Lightweight, easy to install, and easy to use.

Installation

The ghget package can be installed directly using pip.

pip install ghget

Usage

  • Easily download single files given the GitHub url:
$ ghget https://github.com/naiquevin/pipdeptree/blob/master/pipdeptree.py
Downloading pipdeptree.py file...
Done!
  • Use your GitHub token to access your private repos:
$ ghget -t $GITHUB_TOKEN https://github.com/<username>/<private-repo>/blob/master/<file>
  • Recursively download a specific directory from a GitHub repo:
$ ghget https://github.com/pandas-dev/pandas/tree/master/scripts
Downloading scripts directory...
Done!

$ tree
.
└── scripts
    ├── __init__.py
    ├── generate_pip_deps_from_conda.py
    ├── list_future_warnings.sh
    ├── no_bool_in_generic.py
    ├── pandas_errors_documented.py
    ├── sync_flake8_versions.py
    ├── tests
    │   ├── __init__.py
    │   ├── conftest.py
    │   ├── test_no_bool_in_generic.py
    │   ├── test_sync_flake8_versions.py
    │   ├── test_use_pd_array_in_core.py
    │   └── test_validate_docstrings.py
    ├── use_pd_array_in_core.py
    ├── validate_docstrings.py
    └── validate_rst_title_capitalization.py

Options

usage: ghget [-h] [-t TOKEN] url

positional arguments:
  url                   The url for the file or directory you want to download.

optional arguments:
  -h, --help            show this help message and exit
  -t TOKEN, --token TOKEN
                        Your GitHub token. This is needed for accessing private repos or overcoming the unauthenticated request rate limit for the GitHub API.

Limitation

  • The number of files you can download is limited by the GitHub API request rate limit of 60 requests/hour for unauthenticated requests. Currently, ghget makes an HTTP request every time it encounters a directory (not files), so as long as you are downloading less than 60 total directories/hour you shouldn't have any issues. However, you can increase your request rate limit to 5000 requests/hour if you pass your GitHub token as an argument.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ghget-0.1.0.tar.gz (5.0 kB view hashes)

Uploaded Source

Built Distribution

ghget-0.1.0-py3-none-any.whl (5.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page