Created
February 18, 2025 08:05
-
-
Save japaz/f0001db4037dcb8ab03c0764fe9a52f0 to your computer and use it in GitHub Desktop.
Script o get all git repositories in the subdirectories
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 | |
| # Loop through each subdirectory in the current directory | |
| for dir in */; do | |
| if [ -d "${dir}/.git" ]; then | |
| echo "Processing repository: $dir" | |
| ( | |
| # Enter the subdirectory | |
| cd "$dir" || exit 1 | |
| # Check if the repository is shallow | |
| if [ "$(git rev-parse --is-shallow-repository)" = "true" ]; then | |
| echo " Deepening shallow clone..." | |
| git fetch --all --tags --unshallow | |
| else | |
| echo " Fetching updates..." | |
| git fetch --all --tags | |
| fi | |
| # Optional: Add --prune-tags if you want to remove stale local tags | |
| git fetch --all --tags --prune-tags | |
| ) | |
| fi | |
| done | |
| echo "All repositories processed." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment