Skip to content

Instantly share code, notes, and snippets.

@asmattic
Created June 29, 2025 19:54
Show Gist options
  • Save asmattic/4f80adf51e979675c602f66ce3546123 to your computer and use it in GitHub Desktop.
Save asmattic/4f80adf51e979675c602f66ce3546123 to your computer and use it in GitHub Desktop.
Recursively update .git repos within a folder
#!/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