Skip to content

Instantly share code, notes, and snippets.

@jackpot51
Last active November 16, 2017 18:41
Show Gist options
  • Save jackpot51/f31ab4f32290b1365f9f367a56bed1b6 to your computer and use it in GitHub Desktop.
Save jackpot51/f31ab4f32290b1365f9f367a56bed1b6 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -e
if [ -z "$1" ]
then
echo "$0 [git repository]"
exit 1
fi
git clone --bare --recursive "$1" bare
git -C bare ls-remote --quiet --heads | cut -d $'\t' -f2 | while read ref
do
branch="$(basename "$ref")"
git clone --recursive bare -b "$branch" "$branch"
git -C "$branch" remote set-url origin "$1"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment