{"id":20385009,"url":"https://github.com/d-e-s-o/git-foreach","last_synced_at":"2026-05-07T23:03:33.793Z","repository":{"id":83738480,"uuid":"44057250","full_name":"d-e-s-o/git-foreach","owner":"d-e-s-o","description":"Perform a git command on multiple repositories.","archived":false,"fork":false,"pushed_at":"2016-01-02T19:35:48.000Z","size":22,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"devel","last_synced_at":"2025-01-15T08:12:05.945Z","etag":null,"topics":["git","git-command","git-foreach","shell-script"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/d-e-s-o.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-11T15:19:13.000Z","updated_at":"2023-08-20T20:54:59.000Z","dependencies_parsed_at":"2023-03-18T16:03:30.978Z","dependency_job_id":null,"html_url":"https://github.com/d-e-s-o/git-foreach","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d-e-s-o%2Fgit-foreach","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d-e-s-o%2Fgit-foreach/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d-e-s-o%2Fgit-foreach/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d-e-s-o%2Fgit-foreach/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/d-e-s-o","download_url":"https://codeload.github.com/d-e-s-o/git-foreach/tar.gz/refs/heads/devel","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241935267,"owners_count":20044827,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["git","git-command","git-foreach","shell-script"],"created_at":"2024-11-15T02:31:22.148Z","updated_at":"2026-05-07T23:03:28.763Z","avatar_url":"https://github.com/d-e-s-o.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"git-foreach\n===========\n\n\nPurpose\n-------\n\n**git-foreach** is a script performing ``git`` commands on a number of\nrepositories and, thus, allowing for a more flexible management of\nmultiple repositories. The script works by finding all repositories\nbelow the current working directory and invoking the supplied command\nthere. By default, if no custom command is specified, each repository's\nstatus will be displayed.\n\n\nUsage\n-----\n\nA sample invocation can look like this:\n\n```\n$ git foreach\n/dir/repo3\n M modified-file.py\n/repo2\nD  deleted-file.asm\n/repo1\nA  newly-added-file.c\n```\n\nIn order for batch operations to be able to reference the repository a\ncommand is invoked in, **git-foreach** provides a special variable,\n``REPO``. The variable contains the name of the very repository the\ncommand is invoked in (i.e., the name of the directory the repository is\ncontained in).\n\nAn example incorporating this variable looks as follows:\n\n```\n$ git foreach remote add github 'git@github.com:d-e-s-o/${REPO}.git'\n$ git foreach remote -v\n/dir/repo3\ngithub  git@github.com:d-e-s-o/repo3.git (fetch)\ngithub  git@github.com:d-e-s-o/repo3.git (push)\n/repo2\ngithub  git@github.com:d-e-s-o/repo2.git (fetch)\ngithub  git@github.com:d-e-s-o/repo2.git (push)\n/repo1\ngithub  git@github.com:d-e-s-o/repo1.git (fetch)\ngithub  git@github.com:d-e-s-o/repo1.git (push)\n```\n\nIt is important to properly escape the variable reference in order to\navoid any substitution by the currently running shell. In the example\nabove, the correct behavior is achieved by putting the string containing\nthe variable reference in single quotes.\n\nIn case one is unsure about the proper escaping or just wants to double\ncheck the to-be-invoked command, the -n/--dry-run option can be used:\n\n```\n$ git foreach --dry-run remote add github 'git@github.com:d-e-s-o/${REPO}.git'\n./dir/repo3\ngit remote add github git@github.com:d-e-s-o/repo3.git\n./repo2\ngit remote add github git@github.com:d-e-s-o/repo2.git\n./repo1\ngit remote add github git@github.com:d-e-s-o/repo1.git\n```\n\nUsing this option, the command that is about to be executed is shown for every\nrepository. No action aside from that is actually performed.\n\nAs was apparent from the examples shown so far, **git-foreach** by default\nprints the directory an action is performed (or is to be performed) in before\nthe result of the command is displayed. Using the -q/--quiet option, the script\ncan be silenced:\n\n```\ngit foreach --dry-run --quiet remote add github 'git@github.com:d-e-s-o/${REPO}.git'\ngit remote add github git@github.com:d-e-s-o/repo3.git\ngit remote add github git@github.com:d-e-s-o/repo2.git\ngit remote add github git@github.com:d-e-s-o/repo1.git\n```\n\nIf you want to pass additional command line options to the ``git`` command to\nrun in each repository, you should separate the command along with its options\nso that those options are not interpreted by **git-foreach**. E.g.,\n\n```git foreach -- diff -U10```\n\n\nInstallation\n------------\n\nBeing a simple shell script, installation is straight forward: The script needs\nto be made executable and included in the command search path (in general\nrepresented by the ``PATH`` variable).\n\nDue to the script's name, ``git`` will recognize the command as well, so it can\nbe invoked as ``git foreach`` but also via ``git-foreach``.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd-e-s-o%2Fgit-foreach","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fd-e-s-o%2Fgit-foreach","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd-e-s-o%2Fgit-foreach/lists"}