Skip to content

Instantly share code, notes, and snippets.

@jonlong
Created August 12, 2013 15:01
Show Gist options
  • Save jonlong/6211598 to your computer and use it in GitHub Desktop.
Save jonlong/6211598 to your computer and use it in GitHub Desktop.
Archive/Restore Git Repos to/from GitHub

Archive a GitHub Repository

git clone --bare git@github.com:jonlong/<repo>.git
tar -czf <repo>.git.tar.gz <repo>.git

Deploy an Archived Repository to GitHub

Create a new private repository on the target account:

curl -F 'login=<user>' -F 'token=<token>' -F 'name=jonlong/<repo>' -F 'public=0' http://github.com/api/v2/json/repos/create

Extract the archived repository:

tar -xvzf <repo>.tar.gz

Navigate to the bare repository:

cd <repo>.git

Push the repository to GitHub

git push --mirror git@github.com:jonlong/<repo>.git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment