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
gitandghcommands across multiple repositories with a single command. - Supports all
gitandghcommands with their original specifications. - Offers flexibility in selecting repositories using an interactive picker or the
-allflag 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
.zshrcor.bashrcfile and add the following alias:export mgit="node /path/to/multi-repo-git/mgit.js"
Replace
/path/to/multi-repo-gitwith the path where you cloned the repository. -
Set up GitHub CLI: Ensure you have the
ghCLI installed and authenticated to interact with your GitHub account:gh auth login
-
Create the
.mgit-reposJSON file: In your home directory, create a file named.mgit-reposwith 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-xwith the actual paths to your repositories.
You can choose which repositories to target in two ways:
-
Using the
-allArgument: To run a command on all repositories listed in your.mgit-reposfile, include the-allflag right aftermgit:mgit -all git status
This command will execute
git statusacross all the repositories defined in the.mgit-reposfile. -
Interactive Picker: If you omit the
-allflag, 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"