#!/bin/bash -e parent=$(realpath $1) dest=$2 git new-workdir $parent $dest cd $dest git submodule init for sm in $(git submodule status | awk '{print $2}'); do c=submodule.$sm.url git config --local --replace-all $c $parent/$sm git submodule update --init $sm git submodule sync $sm done git submodule update