LinuxCommandLibrary

git-bulk

Run Git commands across multiple repositories

TLDR

Register the current directory as a workspace

$ git bulk --addcurrent [workspace_name]
copy

Register a workspace for bulk operations
$ git bulk --addworkspace [workspace_name] [/absolute/path/to/repository]
copy

Clone a repository inside a specific directory, then register the repository as a workspace
$ git bulk --addworkspace [workspace_name] [/absolute/path/to/parent_directory] --from [remote_repository_location]
copy

Clone repositories from a newline-separated list of remote locations, then register them as workspaces
$ git bulk --addworkspace [workspace_name] [/path/to/root/directory] --from [/path/to/file]
copy

List all registered workspaces
$ git bulk --listall
copy

Run a Git command on the repositories of the current workspace
$ git bulk [command] [command_arguments]
copy

Remove a specific workspace
$ git bulk --removeworkspace [workspace_name]
copy

Remove all workspaces
$ git bulk --purge
copy

SYNOPSIS

git bulk [options] <git command>

PARAMETERS

--config <file>
    Specifies the configuration file to use. Default is ~/.git-bulk-repos

--git <git executable>
    Specifies the path to the git executable. Default is to use 'git' found on your path.

--jobs <n>
    Number of concurrent processes to use (Default: number of CPUs).

--continue-on-error
    Continue running the commands even if an error occurs on some repos (Default: stop on error)

--only-failed
    Run only on repositories that failed in a previous run (based on previous state file).

--state-file <file>
    Specify a custom state file (Default: ~/.git-bulk-repos.state).

DESCRIPTION

git-bulk simplifies executing Git commands across multiple repositories simultaneously. This is incredibly useful for applying changes, checking status, or performing other operations on a large set of Git repositories managed under a single directory or configuration file. It reads a configuration file that specifies the repositories to operate on and then iterates through each repository, executing the specified Git command. The tool can significantly reduce the time and effort required to manage multiple Git repositories. Error handling is included to prevent the process from stopping if a command fails in one repository, ensuring that as many repositories as possible are processed. Output is directed to stdout, allowing the user to assess the results in terminal.

CAVEATS

The git-bulk command depends on the specified git executable being available. The execution of commands on a huge set of repositories concurrently could exhaust available system resources such as file handles or memory, particularly if the machine has a low number of CPUs or limited memory. Ensure proper configurations are made to account for potential issues such as resource exhaustion.

CONFIGURATION FILE FORMAT

The configuration file used by git-bulk is a simple text file where each line represents a path to a Git repository. Each line should specify a path to the root of git repository.

EXAMPLE USAGE

To commit and push all changes across all repos: git bulk 'git add . && git commit -m "Automated commit" && git push'
To get the status of all git repositories
git bulk 'git status'

HISTORY

While an exact creation date for git-bulk is hard to identify, the general concept of running commands in bulk across multiple Git repositories has likely existed as scripts or ad-hoc solutions for some time. Dedicated tools like git-bulk emerged to streamline this process, offering features such as configuration file management, error handling, and concurrency control. The need for such tools grew as organizations adopted microservices architectures and managed increasingly large numbers of Git repositories. The tool is likely developed to enhance bulk repository management and automation for the users.

SEE ALSO

git(1), find(1), xargs(1), parallel(1)

Copied to clipboard