Helper script for working with multiple git repositories.
Project description
mxrepo
Helper script for working on multiple git repositories in a specific directory.
This script is useful if you work with mxdev sources for project development or if you want to perform backups of a GitHub account.
The tool operates on all git repositories found in the current directory (those containing a .git folder) and executes git commands across them in batch.
Features
- Batch Operations: Execute git commands across multiple repositories at once
- GitHub Integration: Clone or backup all repositories from a GitHub organization or user
- Zero Dependencies: Uses only Python standard library (no external packages required)
- Smart API Access: Automatically tries organization endpoint first, then falls back to user endpoint
- Selective Operations: Target specific repositories or operate on all found repos
- Works with mxdev: Designed for managing mxdev source checkouts during development
Prerequisites
- Python 3.9 or higher
- Git must be installed and available in PATH
- GitHub Access: For
cloneandbackupcommands, repositories must be accessible via GitHub's public API (no authentication is performed)
Installation
From PyPI
pip install mxrepo
For Development
git clone https://github.com/mxstack/mxrepo
cd mxrepo
make install # Sets up virtual environment and installs dependencies
Usage
Parameters
<CONTEXT>: GitHub organization or user name (e.g.,mxstack,octocat)[<PACKAGE>]: Optional repository name(s) to filter operations. When omitted, operates on all repositories found in the current directory
Commands
| Command | Description | Usage | Example |
|---|---|---|---|
clone |
Clone repositories from GitHub org/user | mxrepo clone <CONTEXT> [<PACKAGE>...] |
mxrepo clone mxstack mxdev |
backup |
Backup all repos from org/user (bare mirrors) | mxrepo backup <CONTEXT> |
mxrepo backup myorganization |
pull |
Pull latest changes from origin | mxrepo pull [<PACKAGE>...] |
mxrepo pull |
status |
Show git status for repositories | mxrepo status [<PACKAGE>...] |
mxrepo status myproject |
branch |
List branches in repositories | mxrepo branch [<PACKAGE>...] |
mxrepo branch |
diff |
Show git diff for repositories | mxrepo diff [<PACKAGE>...] |
mxrepo diff |
commit |
Commit all changes with message | mxrepo commit "<MESSAGE>" [<PACKAGE>...] |
mxrepo commit "Fix: update deps" |
push |
Push committed changes to origin | mxrepo push [<PACKAGE>...] |
mxrepo push |
checkout |
⚠️ Discard all uncommitted changes | mxrepo checkout [<PACKAGE>...] |
mxrepo checkout |
⚠️ Warning: The checkout, commit, and push commands are destructive operations. Use with caution.
Examples
Clone all repositories from an organization
mxrepo clone mxstack
This fetches all repositories from the GitHub organization mxstack and clones them into the current directory.
Clone specific repositories only
mxrepo clone mxstack mxdev mxmake
Clones only mxdev and mxmake from the mxstack organization.
Backup all repositories from a user account
mkdir backups
cd backups
mxrepo backup octocat
Creates bare mirror clones of all repositories belonging to the GitHub user octocat. The backup command creates a subfolder named after the context.
Update all local repositories
mxrepo pull
Executes git pull origin <current-branch> in all git repositories found in the current directory.
Check status across all projects
mxrepo status
Shows git status for each repository, useful for seeing which projects have uncommitted changes.
Commit changes across multiple repositories
mxrepo commit "Update dependencies to latest versions"
Commits all changes in each repository with the same commit message. Equivalent to git commit -am "message" in each repo.
Update only specific repositories
mxrepo pull project1 project2
Pulls changes only for project1 and project2 repositories.
How It Works
- Repository Discovery: Scans the current directory for subdirectories containing a
.gitfolder - Batch Execution: Changes into each repository directory and executes the git command
- GitHub API: For
cloneandbackupcommands, queries GitHub's REST API to fetch repository lists:- Tries organization endpoint:
https://api.github.com/orgs/{context}/repos - Falls back to user endpoint:
https://api.github.com/users/{context}/repos - Handles pagination (50 repos per page)
- Tries organization endpoint:
- Branch Detection: Automatically detects the current branch for pull and push operations
Development
This project uses the MXStack tooling (mxdev and mxmake) for development.
Setup
make install # Set up virtual environment and install dependencies
Code Quality
make check # Run all checks (ruff + isort)
make format # Auto-format code (ruff + isort)
Cleanup
make clean # Remove virtual environment and generated files
make runtime-clean # Remove Python cache files (__pycache__, *.pyc)
Tools Used
- ruff: Linting and formatting
- isort: Import sorting (black profile, single-line imports)
- uv: Fast Python package installer
Project Structure
src/mxrepo/main.py: Single-module implementation with all functionality- No external dependencies (uses only Python stdlib)
- Simple argparse-based CLI with subcommands
Related Projects
- mxdev: Tools for managing multiple Python packages in development
- githelper: Original project that mxrepo was based on
Copyright
- Copyright (c) 2025 mxstack Contributors
- BSD 2-clause license (see LICENSE.md)
Contributors
- Robert Niederreiter
- Johannes Raggam
Changelog
1.0.0
- Added tests, CI workflows and hatchling/ trusted publishing and
--versionoption [@jensens, 2025-11-03] - Initial porting from https://github.com/rnixx/githelper [@rnix, 2025-03-03]
License
Copyright (c) 2025, mxstack Contributors
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mxrepo-1.0.0.tar.gz.
File metadata
- Download URL: mxrepo-1.0.0.tar.gz
- Upload date:
- Size: 18.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ef502c7f541f18fbb056f4ddacfaab5c57e9b6d88dbef5ba61ad3d13380c72d
|
|
| MD5 |
41b01dd81dcd17551aa3d4569d0c2396
|
|
| BLAKE2b-256 |
dce119f16e68b0c017d24e73cbcc821a76d15e4ae111884479b00fc4283a354a
|
Provenance
The following attestation bundles were made for mxrepo-1.0.0.tar.gz:
Publisher:
release.yml on mxstack/mxrepo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mxrepo-1.0.0.tar.gz -
Subject digest:
4ef502c7f541f18fbb056f4ddacfaab5c57e9b6d88dbef5ba61ad3d13380c72d - Sigstore transparency entry: 662792159
- Sigstore integration time:
-
Permalink:
mxstack/mxrepo@ba62a7a25d6ff2bba278982b56a0761f57756c5a -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/mxstack
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ba62a7a25d6ff2bba278982b56a0761f57756c5a -
Trigger Event:
release
-
Statement type:
File details
Details for the file mxrepo-1.0.0-py3-none-any.whl.
File metadata
- Download URL: mxrepo-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24d08d53f412d9d7a25fd2ad1d418053697b7ae525e92d8d153b0588c28ba75f
|
|
| MD5 |
10762a34f12048854f0a80d41a2f2f81
|
|
| BLAKE2b-256 |
113dfb89bfa53feab32432e292cb528512ff21d9baed740a3290071b980f779d
|
Provenance
The following attestation bundles were made for mxrepo-1.0.0-py3-none-any.whl:
Publisher:
release.yml on mxstack/mxrepo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mxrepo-1.0.0-py3-none-any.whl -
Subject digest:
24d08d53f412d9d7a25fd2ad1d418053697b7ae525e92d8d153b0588c28ba75f - Sigstore transparency entry: 662792200
- Sigstore integration time:
-
Permalink:
mxstack/mxrepo@ba62a7a25d6ff2bba278982b56a0761f57756c5a -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/mxstack
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ba62a7a25d6ff2bba278982b56a0761f57756c5a -
Trigger Event:
release
-
Statement type: