Skip to content

Instantly share code, notes, and snippets.

@japaz
Created February 18, 2025 08:05
Show Gist options
  • Select an option

  • Save japaz/f0001db4037dcb8ab03c0764fe9a52f0 to your computer and use it in GitHub Desktop.

Select an option

Save japaz/f0001db4037dcb8ab03c0764fe9a52f0 to your computer and use it in GitHub Desktop.
Script o get all git repositories in the subdirectories
#!/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