#!/usr/bin/env bash if [ $# -ne 1 ]; then echo "usage: clone " exit 1 fi set -xe USER="compromyse" base_dir="$HOME" new_repo="${base_dir}/$1" case $new_repo in *\.git) ;; *) new_repo="${new_repo}.git" ;; esac if [ -d "$new_repo" ]; then echo "$new_repo already exists" exit 1 fi mkdir "$new_repo" git clone --bare "git@github.com:$USER/$1" "$new_repo" pushd $new_repo > /dev/null for remote in $(git remote show); do git remote remove $remote git remote add github git@github.com:$USER/$1 git fetch github done echo "$description" > description echo 'git push github -f --mirror' > "hooks/post-receive" chmod +x "hooks/post-receive" popd > /dev/null