Skip to content

Instantly share code, notes, and snippets.

@kenpusney
Created June 1, 2020 07:34
Show Gist options
  • Save kenpusney/c217bfc8b6233695ab58eeb86f9beb5f to your computer and use it in GitHub Desktop.
Save kenpusney/c217bfc8b6233695ab58eeb86f9beb5f to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Subtree archive script
# -------
#
# Archive your repos into single and keeps all commit history.
#
# Please change github username before you use.
REPO=$1
BRANCH=${2:-"master"}
USER=kenpusney
die() {
echo $1
exit -1;
}
[ -z $REPO ] && die "error, usage \`${0} \$REPO [\$BRANCH]\`"
git remote add subtree-${REPO} git@github.com:${USER}/${REPO}.git
git subtree add --prefix=${REPO} subtree-${REPO} ${BRANCH}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment