Skip to content

Instantly share code, notes, and snippets.

@srivastavarobin
Last active December 19, 2015 13:08
Show Gist options
  • Save srivastavarobin/5959536 to your computer and use it in GitHub Desktop.
Save srivastavarobin/5959536 to your computer and use it in GitHub Desktop.
Backup of GitHub Repo

Why?

Over a period of time the active development stops on various projects and we don't need those using our private repo slots in GitHub (which ultimately leads to hogging up $$$ for those projects). To avoid this we archive our GitHub repo and free up the paid slots from GitHub.

What??

Step-by-Step process to create bundle of an entire Git repo, and, subsequently extracting it and transferring it to another Git repo.

With this, closed project can be archived into a single file and saved at some other location. Whenever needed it can be brought back with the entire commit history of the branches.

Cloning and Creating a Bundle

  • Clone the repo
git clone <URL>
  • Get all the branches
git remote update
git pull --all
  • Here is where it get a bit manual (if I don't get some straight forward command for this then will have to write a quick script). Checkout all the branches and track them
git checkout -t origin/branch1
git checkout -t origin/branch2
.
.
.
git checkout -t origin/branchn
  • Create a bundle
git bundle create proj.repo --all

Extracting the bundle

  • Clone the repo from the bundle
git clone proj.repo <directory name where you want to extract it>
  • Checkout all the branches
git checkout -t origin/branch1
git checkout -t origin/branch2
.
.
.
git checkout -t origin/branchn
  • Push to the new GitHub repo
git push <remote-alias> --all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment