Migrating Git hosts
I’m currently evaluating options for Git repository hosting services for my team. I’m partial to using GitHub, but there may be reasons that we would instead (or in addition) want to use Atlassian’s Stash.
With Git is it possible to copy a repository and its history from hosting service to another? Are there any gotchas with doing this? If we go down one provider and decide we have to switch later then is there anything that we would lose?
I am interested in the general answer about this for Git, but also are there any likely issues with data (not necessarily just source version history) stored as part of that would be lost by trying to migrate specifically between the GitHub and Atlassian stacks?
== update (v2) ==
Just to follow up, I did successfully do this from the clone I had from Stash and push to Github by using:
git clone --mirror ssh://email@example.com:8080/Stash/Project.git MyGithubProject cd MyGithubProject git remote set-url origin firstname.lastname@example.org:MyGithubOrg/MyGithubProject.git git push --mirror origin
And it retained all the expected history, including branches.
2 Solutions collect form web for “Migrating Git hosts”
Joe, per your comment, the question doesn’t make much sense in the context of git. Any clone of your repository contains the entire history of the repository. That written, there are three things you’d need to recreate if you changed services:
Any git hooks setup on github. These aren’t stored with the repository (for any cloned repository). However, there’s no reason you couldn’t version control them, too, so recreating them on any service would be easy. This is also a good practice. Version control anything you care about.
Users permissioned to access the repository. Obviously, any service change means your developers would have to get accounts on that service, get permissioned to view the company repository, etc.
Personal developer repositories. Forks of your company repo will obviously need to be recreated on the new service, but this is a trivial operation once you’ve done -2- and kept -1- in mind. You could do it as easily as David describes in his answer.
I just tested this with two different remotes and by adding the new, removing the old, and pushing, the commit history was not lost.