Skip to content

Instantly share code, notes, and snippets.

@lek890
Created May 17, 2021 10:12
Show Gist options
  • Save lek890/cdee04b55341fd71dd941f8ffa205e0a to your computer and use it in GitHub Desktop.
Save lek890/cdee04b55341fd71dd941f8ffa205e0a to your computer and use it in GitHub Desktop.
Clone all existing git repos to a new folder
#!/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