Created
January 11, 2021 14:51
-
-
Save alwalker/fd3c19b2c0a751197c7629a840cc33ce to your computer and use it in GitHub Desktop.
Search current directory for git repos and generate script to recreate them.
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
set -e | |
echo "set -e" > gitbuilder.sh | |
dirs=() | |
readarray -d '' dirs < <(find . -name .git -type d -prune) | |
for dir in ${dirs[@]}; do | |
cleandir=$(echo $dir | sed 's/\.git//') | |
remote=$(git --git-dir=$dir remote -v | grep fetch | sed -r 's/origin\s+//' | sed -r 's/\s+\(fetch\)//') | |
echo "" >> gitbuilder.sh | |
echo "mkdir -p $cleandir" >> gitbuilder.sh | |
echo "git clone $remote $dir">> gitbuilder.sh | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment