Created
May 17, 2021 10:12
-
-
Save lek890/cdee04b55341fd71dd941f8ffa205e0a to your computer and use it in GitHub Desktop.
Clone all existing git repos to a new folder
This file contains 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 | |
if [ "$1" == "-h" ]; then | |
echo "All subdirectories in the folder from which this script is run would be cloned to a new destination. Pass the destination url as the argument." | |
exit 0 | |
fi | |
remoteurls=() | |
dirs=($(find . -maxdepth 1 \( ! -name . \) -type d)) | |
for dir in "${dirs[@]}"; do | |
cd "$dir" | |
url=`git config --get remote.origin.url` | |
remoteurls+="$url " | |
cd .. | |
done | |
cd $1 | |
for eachurl in $remoteurls | |
do | |
git clone $eachurl | |
done | |
printf "\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment