Last active
August 8, 2025 08:57
-
-
Save mkjsix/7adce1aefb93c5be403c7ae6f487281b to your computer and use it in GitHub Desktop.
Apply a git command recursively in all folders
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # git-all.sh - Execute git commands on all repositories recursively | |
| # Usage: ./git-all.sh "pull --rebase" | |
| # ./git-all.sh "status" | |
| # ./git-all.sh "fetch" | |
| if [ $# -eq 0 ]; then | |
| echo "Usage: $0 \"git-command\"" | |
| echo "Examples:" | |
| echo " $0 \"pull\"" | |
| echo " $0 \"pull --rebase\"" | |
| echo " $0 \"status\"" | |
| echo " $0 \"fetch\"" | |
| exit 1 | |
| fi | |
| find . -type d -name .git -exec sh -c "cd \"{}\"/../ && pwd && git $1" \; |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example usage:
$ ./git-all.sh "pull --rebase"