Skip to content
README.md 3.13 KiB
Newer Older
Srdjan Grubor's avatar
Srdjan Grubor committed
gh_fetch
========
### Downloader and updater for your github repos.
Srdjan Grubor's avatar
Srdjan Grubor committed

Srdjan Grubor's avatar
Srdjan Grubor committed
- Did you ever needed to keep a backup of a large number of GitHub repos?
Srdjan Grubor's avatar
Srdjan Grubor committed
- Did you ever need to start using your dev machine quickly but had to clone repos one by one?
- Did you ever need to update (fetch) a ton of repositories from GitHub but you had to do it one by one?

Srdjan Grubor's avatar
Srdjan Grubor committed

Srdjan Grubor's avatar
Srdjan Grubor committed
**gh_fetch** is designed to fix all of these problems by automating the process to the maximum extent possible. This tool will go through your (or another account's) GitHub repos both public and private including repositories from organizations you are a member of and fetch the most recent changes for it, cloning the relevant repos if they are not already downloaded. Feature set will be expanding per my current needs but you are free to fork and issue a pull request.
Srdjan Grubor's avatar
Srdjan Grubor committed

**Note: This code works with both Python3 (default) and Python2 (when invoked with `python2` prefix)**

Srdjan Grubor's avatar
Srdjan Grubor committed
```
Srdjan Grubor's avatar
Srdjan Grubor committed
$ ./update_repos -h
usage: update_repos [-h] [--version] [-d DIRECTORY] [-t TOKEN_FILE] [-s] [-m]
                    [-x] [--exclude-forks] [--exclude-orgs]
                    [--include-org-forks] [--include-public-org-repos]
                    [--full-backup] [--debug]
Srdjan Grubor's avatar
Srdjan Grubor committed
                    username [token]
Srdjan Grubor's avatar
Srdjan Grubor committed

Retrieve and/or update local copies of GitHub-hosted repos

positional arguments:
Srdjan Grubor's avatar
Srdjan Grubor committed
  username              GitHub username that will be used for cloning and
                        fetching
  token                 GitHub auth token for that username. You can create
                        one at https://github.com/settings/applications
Srdjan Grubor's avatar
Srdjan Grubor committed

optional arguments:
  -h, --help            show this help message and exit
Srdjan Grubor's avatar
Srdjan Grubor committed
  --version             show program's version number and exit
Srdjan Grubor's avatar
Srdjan Grubor committed
  -d DIRECTORY, --directory DIRECTORY
Srdjan Grubor's avatar
Srdjan Grubor committed
                        Target directory for cloning and fetching
Srdjan Grubor's avatar
Srdjan Grubor committed
  -t TOKEN_FILE, --token-file TOKEN_FILE
                        File containing the github token
  -s, --ssh             Fetch repositories using ssh
  -m, --mirror          Mirror bare repositories instead of making full
                        checkouts
Srdjan Grubor's avatar
Srdjan Grubor committed
  -x, --exclude-own     Exclude own repositories in the updates
  --exclude-forks       Exclude forked repositories from the updates
Srdjan Grubor's avatar
Srdjan Grubor committed
  --exclude-orgs        Exclude repos that are in user's orgs (this does not
                        filter the ones you have)
Srdjan Grubor's avatar
Srdjan Grubor committed
  --include-org-forks   Include forked repos that are in user's orgs
Srdjan Grubor's avatar
Srdjan Grubor committed
  --include-public-org-repos
Srdjan Grubor's avatar
Srdjan Grubor committed
                        Include public repos that are in user's orgs
  --full-backup         Include all repository content
Srdjan Grubor's avatar
Srdjan Grubor committed
  --debug               Enable debugging output
```

## Examples

- Getting all your repos:
```
Srdjan Grubor's avatar
Srdjan Grubor committed
./update_repos -d /opt/checkout --exclude-orgs sgnn7 1234567890abfdefghijkl
Srdjan Grubor's avatar
Srdjan Grubor committed
```

- Backing up all organizational repos:
```
./update_repos -x -d ~/backups --include-org-forks --include-public-org-repos backup-user 1234567890abfdefghijkl
Srdjan Grubor's avatar
Srdjan Grubor committed
```

Srdjan Grubor's avatar
Srdjan Grubor committed
## TODO
Srdjan Grubor's avatar
Srdjan Grubor committed
- Scrubbing of remote endpoints
Srdjan Grubor's avatar
Srdjan Grubor committed
- Lots of testing
Srdjan Grubor's avatar
Srdjan Grubor committed

## Contributors
 - Srdjan Grubor ([@sgnn7](https://github.com/sgnn7))
 - Dan Nicholson ([@dbnicholson](https://github.com/dbnicholson))
 - Will Thompson ([@wjt](https://github.com/wjt))
 - Nimrod Adar ([@adarnimrod](https://github.com/adarnimrod))