Skip to content

marcfrederick/git-foreach

Repository files navigation

git-foreach

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.

Usage

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 || :"

Installation

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.

Homebrew

If you're using macOS or Linux, you can install git-foreach using Homebrew:

brew install --cask marcfrederick/homebrew-tap/git-foreach

Building from Source

To 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 --release

Contributing

Contributions are welcome! Please feel free to submit issues and pull requests on the GitHub repository.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

Lightweight utility designed to execute a command in each Git repository within a directory and its subdirectories

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Contributors

Languages