Created
June 29, 2025 19:54
-
-
Save asmattic/4f80adf51e979675c602f66ce3546123 to your computer and use it in GitHub Desktop.
Recursively update .git repos within a folder
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 | |
# Directory to search for git repositories | |
# Defaults to current directory if no argument is provided | |
SEARCH_DIR="${1:-.}" | |
# Find all .git directories, then go to their parent directory and run git pull | |
find "$SEARCH_DIR" -name ".git" -type d -prune | while IFS= read -r d; do | |
REPO_DIR="$(dirname "$d")" | |
echo "Pulling changes in: $REPO_DIR" | |
(cd "$REPO_DIR" && git pull) | |
echo "--------------------------------------" | |
done | |
echo "All git repositories updated." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment