git-foreach is a lightweight utility designed to execute a command in each Git repository within a directory and its
subdirectories. It's particularly useful for performing bulk operations, such as git pull or git status, across
multiple repositories simultaneously.
To use git-foreach, pass the shell command as one quoted argument. The command will be executed in each Git repository
found in the current directory and all its subdirectories.
git-foreach "<command>"For instance, if you want to execute git pull in each repository, you would use:
git-foreach "git pull"The command is passed to the platform shell (/bin/sh -c on Unix and cmd /C on Windows), so shell expressions such
as pipes, redirects, and || are supported. Quoting the entire command is required; git-foreach git pull is rejected.
Commands run in parallel in every discovered repository. A failure in one repository does not stop commands that run
in the others. After all commands finish, failures are reported and git-foreach exits unsuccessfully. To mask failures,
you can append || : to the command.
$ git-foreach "git pull"
encountered 1 error(s):
- command exited unsuccessfully in ./example-repository: exit status: 1
$ git-foreach "git pull || :"Pre-built binaries are available for Windows, Linux, and macOS. You can download them from
the releases page and add them to your $PATH. The release
page also includes instructions for installation using Homebrew, curl, or PowerShell.
If you're using macOS or Linux, you can install git-foreach using Homebrew:
brew install --cask marcfrederick/homebrew-tap/git-foreachTo build the utility from source, ensure you have Rust installed on your system. Then, execute the following commands:
git clone git@github.com:marcfrederick/git-foreach.git
cd git-foreach
cargo build --releaseContributions are welcome! Please feel free to submit issues and pull requests on the GitHub repository.
This project is licensed under the MIT License. See the LICENSE file for details.