This is a bash script that allows you to clone repositories from a GitHub organization or user. It provides additional functionality through command line flags.
./dlgh.sh [options] organization-name max-page-number
The script supports the following command line flags:
-
--zip
or-z
: When specified, all cloned repositories will be outputted as a .zip compressed archive file. Each repository will be at the top level within the archive. -
--help
or-h
: Prints a usage message, explaining how to use the script and its available options. This message is also displayed if the script is called with no arguments.
To run this script, you need to have the following dependencies installed:
jq
: A lightweight and flexible command-line JSON processor.gh
: The official command-line tool for GitHub.
Before using the script, make sure you are authenticated with GitHub by running the command:
gh auth login
If you are not authenticated, the script will display an error message and exit.
-
organization-name
: The name of the GitHub organization or user from which you want to clone repositories. -
max-page-number
: The maximum number of pages to clone. Each page retrieves up to 100 repositories. If this argument is not provided, the default value is 2.
The script uses the gh repo list
command to retrieve a list of repositories from the specified organization or user. It clones each repository using git clone
command.
The script will iterate through the specified number of pages (or the default if not provided) and clone all repositories found.
- Clone repositories from the "myorg" organization, limiting to 3 pages:
./dlgh.sh myorg 3
- Clone repositories from the "myuser" user and create a .zip archive:
./dlgh.sh --zip myuser
- Display the usage message:
./dlgh.sh --help
- Display the usage message (no arguments):
./dlgh.sh
Please ensure that the script has executable permissions before running it:
chmod +x dlgh.sh
That's it! Enjoy cloning repositories from GitHub using this convenient script. ππ