Skip to content

Instantly share code, notes, and snippets.

@tokumine
Last active December 12, 2015 02:28
Show Gist options
  • Save tokumine/4699030 to your computer and use it in GitHub Desktop.
Save tokumine/4699030 to your computer and use it in GitHub Desktop.
migrate a private github repository to your own hosted git.

How-to migrate your private github repositories to an external server

Because of the recent ruby/rails security scares I wanted to move our private github repository to a more secure location that is only accessible by our small team via ssh keys on an unknown port. It's worth remembering that private repos on github are not encrypted, and so are only as safe as the ruby/network layer that wraps it. To be fair, private repos were never advertised as secure storage, despite being used that way.

This is a huge 'if', but /if/ github is compromised not only will your sourcecode stand a high chance of being exposed (commercial damage, elevated risk of XSS & SQL injection), but your web applications may also be vulnerable to session spoofing in addition to possibly granting access via API keys and passwords to the usual range of external APIs, probably including commercial ones. We all code in a secure way, but who wants to have that tested in public?

It is trivially easy to mitigate this risk

You can setup a git repository on a server on the internet of your choosing that will allow you to continue sharing commits and deploying as normal. You can then remove sensitive information from your repo at your own pace, and, once the rubypocalypse is over, you can always migrate your code back to github if you wish.

Config remote git server and push code there + update your local gits to use the new remote location

http://tumblr.intranation.com/post/766290565/how-set-up-your-own-private-git-server-linux

update your capistrano deploy scripts

As long as you have key based auth over ssh between your servers, it's as simple as updating your cap scripts:

set :repository, "[your ssh user]@[your server]:[your relative path to git repo]"

backup your github issues & delete your github private repo

https://gist.github.com/2369729 (I used this. it worked well. Not sure if I can roundtrip them)

YMMV

@ajturner
Copy link

ajturner commented Feb 2, 2013

If you still want Github-like functionality then look at the free and open-source Gitlab: http://gitlab.org/

We use it at Esri and so far it's been nice to have internally and the optionally to still push things public to Github.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment