Skip to content

Instantly share code, notes, and snippets.

@marcus-nl
Created July 28, 2020 12:19
Show Gist options
  • Save marcus-nl/934264a83ca34b250c3558b69935b9b9 to your computer and use it in GitHub Desktop.
Save marcus-nl/934264a83ca34b250c3558b69935b9b9 to your computer and use it in GitHub Desktop.
Bash index and pull git repositories in workspace
dir="$1"
repo=`cd $dir && git config --get remote.origin.url`
echo "$dir; $repo"
# write list of directories containing .git to dirnames.txt
find -maxdepth 4 -type d -name .git | xargs dirname > dirnames.txt
# add the git origin and write to repos.csv
cat dirnames.txt | xargs -L 1 ./add_origin.sh > repos.csv
while IFS="; " read dir url; do
echo "Cloning $url into $dir..."
git clone "$url" "$dir"
done <repos.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment