clonetool
is a command-line utility written in Rust designed to clone all repositories for specified GitHub or GitLab users or organizations. It's a handy tool for quickly backing up or managing repositories, with added support for pulling updates to existing clones.
- Clones all repositories for specified GitHub or GitLab users or organizations.
- Clones repositories into separate folders named after the user/organization in a specified destination directory.
- Provides a
--debug
flag for verbose output, including executed git commands. - Allows pulling updates (
git pull
) for all branches of existing repositories using the--pull
or-p
flag. - Excludes specific repositories using the
--exclude
or-x
flag. - Supports GitHub and GitLab providers via the
--provider
flag. - Automatically creates missing destination directories.
- Rust: Make sure you have Rust installed. You can download it from rust-lang.org. (Cargo is included with the Rust installation.)
- Git: Ensure that Git is installed and available in your system's
PATH
.
-
Clone or download the source code for
clonetool
. -
Navigate to the root directory of the project (where
Cargo.toml
is located). -
Build the tool using Cargo:
cargo build --release
This will create an optimized version of the tool located in the
target/release
directory.
The basic usage of clonetool
is:
clonetool -u <usernames> -d <destination_directory> [options]
-u, --users <usernames>
: A comma-separated list of GitHub or GitLab usernames or organization names.-d, --destination <destination_directory>
: The local directory to clone repositories into.--debug
: Enables debug output, showing executed git commands.-p, --pull
: Pulls updates (git pull
) for all branches of repositories in the specified destination directory.-x, --exclude <packages>
: A comma-separated list of repositories to exclude, in the formuser/package
.--provider <provider>
: Specifies the provider (github
orgitlab
). Defaults togithub
.
-
Clone all repositories for a user from GitHub to the
/home/user/repos
directory:clonetool -u testuser -d /home/user/repos
This will create a directory called
testuser
inside therepos
directory and clone all repositories inside. -
Clone all repositories for multiple users from GitHub:
clonetool -u user1,user2,org -d /mnt/data/repos
This will create directories
user1
,user2
, andorg
inside/mnt/data/repos
, with each user's repositories cloned inside their respective directories. -
Pull updates for existing repositories:
clonetool -u testuser -d /home/user/repos --pull
This will traverse the
/home/user/repos/testuser
directory and rungit pull
for all branches of each repository. -
Clone repositories while excluding specific repositories:
clonetool -u testuser -d /home/user/repos -x testuser/repo1,testuser/repo2
This will clone all repositories from
testuser
, exceptrepo1
andrepo2
. -
Clone repositories from GitLab:
clonetool -u testuser -d /home/user/repos --provider gitlab
This will clone all repositories for
testuser
from GitLab. -
Pull updates for multiple users:
clonetool -u user1,user2,org -d /mnt/data/repos --pull
This will pull updates for repositories inside
/mnt/data/repos/user1
,/mnt/data/repos/user2
, and/mnt/data/repos/org
.
- When using
--pull
, the tool assumes the repositories already exist in the destination directory. - The tool supports both GitHub and GitLab APIs for fetching repository lists.
- The program will create the specified destination directory if it does not exist.
- Usernames/organization names must only contain alphanumeric characters, underscores, or hyphens.
- The
--exclude
flag requires repository names in the formatuser/repository
.
This project is open source and available under the MIT License. The full text of the license can be found in the LICENSE
file.
This tool was created with the assistance of ChatGPT 4o and Google Gemini 2.0 Flash.