Transfer Your Existing Git Repository to Github

I published a post before on How To Create a Remote Shared Git Repository and have recently seen people asking on how to then transfer those kind of repositories to Github. Seriously, this is a one-liner!

Of course we all love Github, with the Issues feature, a Wiki section and a full-blown visual interface to your Git repositories, so sooner or later you might want to switch from your self-hosted Git repository to Github. It turns out that it’s one of the easiest things to do, yet another reason to love Git ;)

So assuming you’re in your Git project directory on your local machine, you’ve committed your latest changes and pushed them to your remote Git repository. Assuming also that you got yourself a new Github-hosted repository, here’s what you need to do to move over:

 $ git push --mirror git@github.com:username/project.git

And that’s it, my oh my! Really, that was simple. Now if you want to completely move over to Github then go edit your Git settings (it’s a file called config in the .git directory under the root of your project) and find the line that says “url =”, change the URL to that very same git@github.com:username/project.git and save the file.

And.. Congratulations, you’re done! What? Were you expecting more? ;)

About the author

Konstantin Kovshenin

WordPress Core Contributor, ex-Automattician, public speaker and consultant, enjoying life in Moscow. I blog about tech, WordPress and DevOps.

3 comments