How to clone any Github repository in one simple command

Why

How

gem install github-cloner
github-cloner

Which should give you something like


Usage: github-cloner [options]

Specific options:
    -b, --base-dir BASE_DIR          where BASE_DIR is the directory where the repositories will be cloned to (mandatory)
                                     If not specified, current directory will be used
    -u, --user USER                  The Github USER that will be cloned from (mandatory)
    -o, --org [ORG]                  The Github's organization name to be used if specified (optional)
                                     where ORG is the organization that the user belongs to
    -t, --oauth-token [OAUTH_TOKEN]  The Github's oauth_token for authentication (optional - only required to list/clone private repositories)
                                     where OAUTH_TOKEN is from the user's Github setting
    -l, --language [LANG]            Clone only project of type LANG (optional)
                                     where LANG is main language as shown on Github
    -a, --[no-]all-repos             All repository only (optional)
                                     default to original/non-forked repositories only
    -g, --[no-]group-by-user         Group the output by {BASE_DIR}/{USER}/{LANG}
                                     default to {BASE_DIR}/{LANG}/{USER}
    -c, --[no-]clone                 Clone the repositories to the path specified (optional)
                                     default to --no-clone e.g. dry-run only

Common options:
    -h, --help                       Show this message

Example Usage:

a) List the 'JavaScript' repositories for a given user (dry-run)
github-cloner -b ~/Desktop/projects -u awesome_user -l JavaScript

b) Clone the 'JavaScript' repositories for a given user (note: --clone or -c option)
github-cloner -b ~/Desktop/projects -u awesome_user -l JavaScript -c

Basic Usage

List repositories by user or organization id
# List all original/non-forked repositories by `awesome_user`
$github-cloner --user awesome_user

## List all original/non-forked repositories of a user `awesome_user` that belongs to `AwesomeCo`
$github-cloner --user awesome_user --org AwesomeCo

## List all origina/non-forked repositories by user `awesome_user` including private repository
# Note: for this to work you will need to have the proper access with the right token
$github-cloner --user awesome_user --oauth-token GITHUB_TOKEN_FOR_THIS_USER

## List all repositories by user `awesome_user` include forked repositories
$github-cloner --user awesome_user --oauth-token GITHUB_TOKEN_FOR_THIS_USER
List and clone repositories by user or organization id using --clone option
## Clone all original (non-fork) public `JavaScript` repositores for user `awesome_user` to `~/Desktop/github`
# Note: --base-dir is optional, if not specified then the current directory will be used
#       --language must be quoted if the value include any spaces e.g. "Emacs Lisp" for this to to work properly
$github-cloner --user awesome_user \
               --base-dir ~/Desktop/github \
               --language "JavaScript" \
               --clone

## Clone all public/private repositories for `awesome_user` which are member of `AwesomeCo` organization to `~/Desktop/github`
# Note: the option `--all` to include all forked repositories
$github-cloner --user awesome_user \
               --org AwesomeCo \
               --all-repos \
               --base-dir ~/Desktop/github \
               --oauth-token GITHUB_TOKEN_FOR_AWESOME_USER \
               --clone

## Clone specific type of project (e.g. `Java` in this case) public/private repositories for `awesome_user`
## which are member of `AwesomeCo` organization to `~/Desktop/github`
$github-cloner --user awesome_user \
               --org AwesomeCo \
               --all-repos \
               --language "Java" \
               --base-dir ~/Desktop/github \
               --oauth-token GITHUB_TOKEN_FOR_AWESOME_USER \
               --clone

Detail Usage

Please see the github-cloner for detail usage/example use-cases

comments powered by Disqus