Multi Repo Git is a command-line tool designed to streamline the management of git
and gh
commands across multiple repositories. By acting as a wrapper around these commands, it enables you to perform operations on multiple repositories simultaneously, reducing the time and effort required for repetitive tasks.
- Execute
git
andgh
commands across multiple repositories with a single command. - Supports all
git
andgh
commands with their original specifications. - Offers flexibility in selecting repositories using an interactive picker or the
-all
flag to target all repositories. - Easy setup and usage with a simple configuration file.
Follow these steps to install and set up Multi Repo Git:
-
Clone the repository:
git clone https://github.com/xristos3490/multi-repo-git.git
-
Navigate to the cloned directory and install dependencies:
cd multi-repo-git npm install
-
Add an alias: Edit your
.zshrc
or.bashrc
file and add the following alias:export mgit="node /path/to/multi-repo-git/mgit.js"
Replace
/path/to/multi-repo-git
with the path where you cloned the repository. -
Set up GitHub CLI: Ensure you have the
gh
CLI installed and authenticated to interact with your GitHub account:gh auth login
-
Create the
.mgit-repos
JSON file: In your home directory, create a file named.mgit-repos
with the following structure:{ "repositories": [ { "name": "Repository 1", "path": "/path/to/repository-1" }, { "name": "Repository 2", "path": "/path/to/repository-2" }, { "name": "Repository 3", "path": "/path/to/repository-3" } ] }
Replace
/path/to/repository-x
with the actual paths to your repositories.
You can choose which repositories to target in two ways:
-
Using the
-all
Argument: To run a command on all repositories listed in your.mgit-repos
file, include the-all
flag right aftermgit
:mgit -all git status
This command will execute
git status
across all the repositories defined in the.mgit-repos
file. -
Interactive Picker: If you omit the
-all
flag, Multi Repo Git will display an interactive picker for you to select the repositories where you want to run the command.
Here are some example workflows using Multi Repo Git:
- Check the status of all repositories:
mgit -all git status
- Create a new branch in each repository:
mgit -all git checkout -b fix/issue
- Add and commit changes:
mgit -all git add . && mgit -all git commit -m "Fix issue"
- Push changes to the remote:
mgit -all git push origin fix/issue
- Create pull requests for each repository:
mgit -all gh pr create --title "Fix issue" --body "Description of the fix"