#!/bin/bash new_pwd=$(dirname $(realpath $0)) cd $new_pwd # remove old data, if exists if [ -d "tool_repos" ] then echo "Removing old tool_repos" rm -Rf "tool_repos" fi echo "Initializing tool_repos" mkdir -p tool_repos/uninitialized.git git init --bare tool_repos/initialized.git git init tool_repos/non-bare-init echo "Preparing submodules for tests.." for repo in test-repo-* do echo ">> $repo" cd $repo for i in $(git for-each-ref --format="%(refname:short)" --no-merged=origin/HEAD refs/remotes/origin); do git switch --track $i; done cd .. done # recover submodules to initial state (branches will remain) git submodule update --init