RepoSync is a powerful command-line tool written in Go for securely cloning all repositories from GitLab groups or GitHub organizations, including nested subgroups (GitLab) with zero-touch authentication configuration.
- Secure token storage - Credentials saved in user home directory with proper permissions
- Complete repository cloning - Clone all repositories from GitLab groups (with subgroups) or GitHub organizations
- Flexible cloning methods - Support for both HTTPS and SSH cloning
- Directory structure preservation - Automatic mirroring of organization hierarchy
- Smart skipping - Automatically skips already cloned repositories
- Progress reporting - Real-time progress indicators during cloning
- Enterprise support - Works with self-hosted GitLab and GitHub Enterprise
- Input validation - Comprehensive validation for all inputs
- Error handling - Robust error handling with retry mechanisms
- Rate limiting - Built-in rate limiting to prevent API throttling
- Git (Download Git)
- Go 1.24+ (Download Go)
go install github.com/itszeeshan/reposync@latest
Move the binary to /usr/local/bin
so it can be used system-wide:
sudo mv $(go env GOPATH)/bin/reposync /usr/local/bin/
Now you can run reposync
from anywhere.
- Configure your credentials (first-time setup):
reposync config
Follow the prompts to enter your GitLab and GitHub personal access tokens. Tokens are entered securely and hidden from terminal history.
- Verify configuration:
cat ~/.reposync/config.json
- GitHub: Personal access token with
repo
scope - GitLab: Personal access token with
read_api
scope
reposync -p <gitlab|github> -g <GROUP_ID|ORG_NAME> [-m <https|ssh>]
Argument | Description | Required |
---|---|---|
-p |
Provider: gitlab or github |
Yes |
-g |
Group ID (GitLab) or Organization name (GitHub) | Yes |
-m |
Clone method: https (default) or ssh |
No |
-h |
Show help message | No |
reposync -p github -g your-organization
reposync -p gitlab -g 123456 -m ssh
reposync -p github -g your-organization -m ssh
RepoSync preserves the exact GitLab group hierarchy:
my-group/ # Parent group
├── backend/ # Subgroup
│ ├── auth-service/ # Repository
│ └── payment-service/
├── frontend/
│ ├── web-app/
│ └── mobile-app/
└── tools/ # Root group repositories
├── ci-cd-templates/
└── monitoring-system/
GitHub repositories are cloned in a flat structure:
my-organization/ # Organization root
├── docs-website/ # Repository
├── api-gateway/
├── user-management/
└── infrastructure-as-code/
Create exact replicas of your organization structure for local development:
my-group/
└── frontend/
└── web-app/ # Matches GitLab's "my-group > frontend > web-app"
Benefits:
- Instant context with paths identical to web interface
- Multi-repo workflows with predictable paths
- Easy navigation between related repositories
Maintain complete organizational structure for backups:
backup-2024/
├── my-group/ # Full hierarchy preserved
│ └── infrastructure/
└── my-organization/ # GitHub repos in flat structure
Benefits:
- Disaster recovery with exact group/repo relationships
- Version snapshots for compliance
- Audit trail maintenance
Use consistent paths for automation scripts:
# Scan all backend services
for repo in my-group/backend/*; do
trivy config "$repo"
done
Benefits:
- Predictable source paths for Docker/K8s builds
- Path-based automation scripts
- Consistent deployment workflows
Configure multi-root workspaces with persistent paths:
{
"folders": [
{ "path": "my-group/frontend/web-app" },
{ "path": "my-group/backend/auth-service" }
]
}
Benefits:
- Persistent workspace configurations
- Cross-repo navigation in IDEs
- Single-window multi-repo development
If you receive permission errors:
reposync config # Update stored credentials
- Rotate tokens: Re-run
reposync config
- Delete credentials:
rm ~/.reposync/config.json
- Check token scopes: Ensure tokens have required permissions
-
Permission denied errors:
- Verify token has correct scopes
- Check if token is expired
- Ensure you have access to the group/organization
-
SSH cloning issues:
- Ensure SSH key is added to your account
- Verify
ssh-agent
is running - Test SSH connection manually
-
Network connectivity:
- Ensure you have network access to GitHub/GitLab
- Check firewall/proxy settings
- Verify DNS resolution
-
Rate limiting:
- Tool includes built-in rate limiting
- Wait and retry if you hit API limits
- Consider using SSH for large organizations
The tool provides specific error messages to help diagnose issues:
- Invalid organization name: Check format (alphanumeric and hyphens only)
- Invalid group ID: Ensure it's a valid integer
- Token validation failed: Token too short or empty
- Repository cloning failed: Network issues or permission problems
RepoSync supports self-hosted GitLab and GitHub Enterprise instances. Configuration can be extended to include custom URLs in the config file.
Real-time progress indicators show:
- Number of repositories found
- Current cloning progress
- Success/failure status for each repository
Built-in retry mechanism for git clone operations:
- Automatic retry on network failures
- Exponential backoff between attempts
- Maximum retry limit to prevent infinite loops
Automatic rate limiting to prevent API throttling:
- 100ms delay between API calls
- Respects GitHub/GitLab rate limits
- Prevents 429 (Too Many Requests) errors
Pull requests are welcome! If you encounter issues, feel free to open an issue on GitHub.
- Clone the repository
- Install dependencies:
go mod download
- Run tests:
go test ./...
- Build:
go build -o reposync .
MIT License. See LICENSE
for details.