Shell Command To Find All Git Repos In Current Directory And Run Git Command

By November 10, 2016March 17th, 2017Blog, Shell/Terminal
Allure Web Solutions Code Snippet

This shell scripts recurses through all child folders to find any git repos and execute a command. In the example below we are executing git pull on all repos inside the current folder.

for git_dir in $(find . -type d -name .git); do git -C $(dirname "$git_dir") pull; done

If you want to run a different command, just replace pull above with any command you want.

Mike Doubintchik

Author Mike Doubintchik

More posts by Mike Doubintchik

Leave a Reply