Skip to content

Instantly share code, notes, and snippets.

@flyingoctopus
Forked from pgib/archive_github_repo.sh
Created October 17, 2011 22:55
Show Gist options
  • Save flyingoctopus/1294096 to your computer and use it in GitHub Desktop.
Save flyingoctopus/1294096 to your computer and use it in GitHub Desktop.
Put this in your shell's respective dot profile and smoke it!
archive_github_repo()
{
if [ ! -d .git ]; then
echo "You must run this from within the root of your git repo."
exit 1
fi
pwd=`pwd`
repo_url=`git config --local --get remote.origin.url`
repo_name=`echo $repo_url | awk -F / '{print $2}' | sed -e s/.git//`
echo "Going to archive ${repo_url} to [email protected]:repositories/archive-${repo_name}.git"
echo "Press Ctrl-C in the next three seconds if this is not what you want..."
sleep 3
echo "Okay, here we go. Creating repo on git.coverallcrew.com..."
ssh homestar.coverallcrew.com create_repo "archive-${repo_name}.git"
echo "Mirroring Github repo (this could take a while)..."
cd /tmp
git clone --mirror $repo_url
cd $repo_name.git
git config --bool core.bare false
git remote add archive [email protected]:repositories/archive-${repo_name}.git
echo "Pushing to archive (this could take a while)..."
git push archive --all
cd /tmp
echo "Cleaning up..."
rm -rf /tmp/$repo_name.git
cd "$pwd"
echo "Repo archived. If you want it, here's how you 'git' it:"
echo "git clone [email protected]:repositories/archive-${repo_name}.git"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment