gmsc
Version:
Git Multi-repo Sync Command - Manage multiple git repositories in parallel
150 lines (113 loc) • 2.62 kB
Markdown
# gms - Git Multi-repo Sync
A CLI tool to manage multiple git repositories in parallel. Execute git commands across all your repositories at once!
## Installation
### Global Installation (Recommended)
```bash
npm install -g gmsc
```
After installation, you can use either `gms` or `gmsc` command.
### Local Development
```bash
cd gms
npm install
npm link # Creates global symlink for testing
```
## Usage
### Initialize
First, navigate to a parent directory containing multiple git repositories as subdirectories:
```bash
cd ~/projects # Contains multiple git repos
gms init
```
This creates a `.gms.json` file tracking all git repositories in subdirectories.
### Commands
#### Show status of all repos
```bash
gms status
```
#### Show current branch in all repos
```bash
gms branch
```
#### Checkout a branch in all repos
```bash
gms checkout main
gms checkout feature/new-feature
```
#### Pull latest changes in all repos
```bash
gms pull
```
#### Push to remote in all repos
```bash
gms push
gms push origin main
gms push origin feature/branch
```
#### Fetch from remote in all repos
```bash
gms fetch
```
#### Execute any git command in all repos
```bash
gms exec "log --oneline -5"
gms exec "stash"
gms exec "merge develop"
```
#### List tracked repositories
```bash
gms list
# or
gms ls
```
## Features
- ✅ Parallel execution for speed
- ✅ Clear status indicators for each repository
- ✅ Works with any git command
- ✅ Configurable through `.gms.json`
- ✅ Progress indicators with ora
- ✅ Colored output with chalk
## How it Works
1. `gms init` scans for all subdirectories containing `.git` folders
2. Creates `.gms.json` to track these as "notional submodules"
3. All commands execute in parallel across tracked repositories
4. Results are displayed with success/failure indicators
## Example Workflow
```bash
# Initialize in your projects folder
cd ~/projects
gms init
# Check status of all projects
gms status
# Switch all projects to main branch
gms checkout main
# Pull latest changes
gms pull
# Create and switch to new feature branch
gms exec "checkout -b feature/awesome"
# After making changes, push all
gms push origin feature/awesome
```
## Configuration
The `.gms.json` file contains:
```json
{
"submodules": [
{
"name": "project1",
"path": "/path/to/project1"
},
{
"name": "project2",
"path": "/path/to/project2"
}
]
}
```
You can manually edit this file to add/remove repositories.
## Requirements
- Node.js >= 16.0.0
- Git installed and configured
- Repositories must be valid git repos
## License
MIT