Skip to main content

git-rexec: Find Git Repositories and Execute Commands Against Them, either Sequentially or in Parallel

Build Status License: GPL v3 PyPI Version Linux Windows macOS

The git-rexec command-line tool recursively locates Git repositories within a directory and executes commands against them, either sequentially or in parallel.

Here are examples demonstrating how to use git-rexec:

Example 1: Execute git status -s across all discovered Git repositories (found by searching recursively under the current working directory) in parallel (-p or --parallel):

git-rexec -p -- git status -s

Example 2: Fetch updates across all discovered repositories, limiting the concurrency to 5 background jobs (-j 5), which helps avoid network congestion or server rate limits when communicating with upstream Git remotes:

git-rexec -j 5 --parallel -- git fetch

Example 3: Include sub-repositories (e.g., Git worktrees and submodules) alongside standard Git repositories during discovery (-s or --include-sub-repos), and execute git status against them:

git-rexec -s -p -- git status

Example 4: Target a specific base directory (~/projects) using the -C flag to recursively discover repositories within it, while explicitly excluding a specific subfolder (~/projects/archive). This example executes git status -s in parallel for all discovered repositories except those within the excluded path:

git-rexec -C ~/projects --exclude-dir ~/projects/archive --parallel -- git status -s

Example 5: Evaluate whether a README.md file exists in the repository (sh -c "test -f README.md"). If the condition returns an exit status of 0 (success), it counts the number of lines in that file (wc -l README.md):

git-rexec --if-exec 'sh -c "test -f README.md"' --parallel -- wc -l README.md

Example 6: Print the paths of all discovered Git repositories:

git-rexec --print

If this helps your workflow, please support the project by ⭐ starring git-rexec on GitHub and sharing it on your website, blog, Mastodon, Reddit, X, LinkedIn, or other social media platforms to help more Git users discover its benefits.

Features

  • Recursively discover Git repositories starting from a specified root directory.
  • Optional flag to include sub-repositories (e.g., Git worktrees and submodules) in the execution target list.
  • Execute shell commands across multiple repositories in parallel using worker threads.
  • Filter target repositories based on the exit code of a conditional check (--if-exec).
  • Exclude specific directories from the search path.
  • Export discovered repository paths for integration with other shell tools (using --print or --print0).

Installation

Here is how to install git-rexec using pip:

pip install --user git-rexec

The pip command above will install the pathaction executable in the directory ~/.local/bin/.

Optional Dependencies

The git-rexec CLI offers optional dependencies that extend its functionality. These extras can be installed according to environment requirements.

Colored Terminal Output (colors): Installs colorama to provide consistent cross-platform ANSI color support. This enhances the readability of standard output and error messages.

pip install "git-rexec[colors]"

Custom Process Title (proctitle): Installs setproctitle to rename the running process from python to git-rexec. This simplifies identification in system monitoring tools such as top, htop, and ps.

pip install "git-rexec[proctitle]"

To install both extras at once, use a comma-separated list:

pip install "git-rexec[colors,proctitle]"

Dependencies

System Dependencies

  • git: Required for repository validation and execution.

Python Dependencies (Optional)

  • colorama: Provides color-coded terminal output.
  • setproctitle: Sets the process title for process monitoring tools.

You can install the optional Python dependencies via pip:

pip install colorama setproctitle

Usage

git-rexec [OPTIONS] -- [exec_cmd ...]

(Assuming the git-rexec script is executable and in your PATH.)

Positional Arguments

  • exec_cmd: The shell command to execute within each discovered Git repository. You can use -- to pass options directly to the command. If omitted, the script simply prints the paths of the discovered repositories.

Options

usage: git-rexec [-h] [-C DIRECTORY] [--exclude-dir EXCLUDE_DIR] [-p] [-i IF_EXEC] [-j MAX_WORKERS] [-q] [-s] [--print] [--print0] [exec_cmd ...]

Find Git repositories and execute commands against them in parallel.

positional arguments:
  exec_cmd              The command to execute. You can use -- to pass options.

options:
  -h, --help            show this help message and exit
  -C, --directory DIRECTORY
                        Root directory to search (defaults to current directory)
  --exclude-dir EXCLUDE_DIR
                        Exclude a specific directory and all of its subdirectories
  -p, --parallel        Execute the command in parallel using threads
  -i, --if-exec IF_EXEC
                        Execute commands only if this check returns exit code 0.
  -j, --jobs MAX_WORKERS
                        Maximum number of processors/workers to use
  -q, --quiet           Quiet mode. Suppresses the informational log prefixes ([EXEC] and [EXEC-P]) that precede execution output.
  -s, --include-sub-repos
                        Include sub-repositories (e.g., Git worktrees and submodules)
  --print               Print the paths (only when no command is provided)
  --print0              Separate the paths with a null character (only when no command is provided)

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Copyright (C) 2019-2026 James Cherti.

Metadata

Release files for git-rexec 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for git-rexec 1.1.0
File Size Uploaded Provenance Actions
git_rexec-1.1.0.tar.gz 36.2 kB Without provenance Details for git_rexec-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for git-rexec 1.1.0
File Interpreter ABI Platform Actions
git_rexec-1.1.0-py3-none-any.whl Python 3 none any Details for git_rexec-1.1.0-py3-none-any.whl

Total release size: 60.4 kB

Release files / git_rexec-1.1.0.tar.gz

Download URL git_rexec-1.1.0.tar.gz
Size 36.2 kB
Tags Source
SHA-256 checksum
How to use checksums
56c8f6b57113f48658325bba68663e52ec001a2b883fd004d9a6c7b7ea6c337d
BLAKE2b-256 checksum
How to use checksums
f71eb823a5cadaa1d7b8f22820ab133505baab5341b3030074416d2338a7f90f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Release files / git_rexec-1.1.0-py3-none-any.whl

Download URL git_rexec-1.1.0-py3-none-any.whl
Size 24.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9af6dc1ef3156a19dcf9c6c84ae9f3a79c347efe7fe4a6c3ca033d515f885de2
BLAKE2b-256 checksum
How to use checksums
6bcea19bdaaa0b00dad5c0dbab0a4079d4e3d3b251a6698aba8be76ee334be9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Security for git-rexec 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page