4

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?

double-beep
  • 5,031
  • 17
  • 33
  • 41
Joe Castro
  • 2,181
  • 18
  • 24
  • 1
    When you clone a git repository you get everything - that is the point of git - you should be able to move it as many times as you like – Adrian Cornish Sep 13 '12 at 01:12
  • But can I clone into a new repository? Looking through GitHub, for example, I can't see how to create a new repository based on one that I started from my local machine. I understand if I had SSH access to the servers I can move, but I'm specifically worried about the limitations when using a host service like Stash or GitHub. I may just be misunderstanding something basic. Please correct me if the concern is silly or the question just doesn't make sense. – Joe Castro Sep 13 '12 at 04:55
  • 1
    All git repositories are created equal (more or less). The one on your box is just as much a repository as the one on github. So if you set the new one as a new remote and push your branches to it, it becomes the same as the other two. – Dan Sep 13 '12 at 13:43

2 Answers2

3

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:

  1. 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.

  2. 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.

  3. 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.

Christopher
  • 42,720
  • 11
  • 81
  • 99
2

I just tested this with two different remotes and by adding the new, removing the old, and pushing, the commit history was not lost.

David Fells
  • 6,678
  • 1
  • 22
  • 34
  • How did you add the "new" here? I think if this is something where I own the server I'm migrating to then this all works in a straightforward way, but I'm not sure how to seed a new project using a preexisting project with either of those hosting services. Thanks, – Joe Castro Sep 13 '12 at 04:58
  • 1
    Create the repo in the new service, then add that repo's Git url as a remote in your working repo where you've currently got the other service's remote. "git add github url.git" - where url.git is the URL to the new repo and github is what you're naming the remote. You can then remove the old remote with "git remove origin" and push all your branches. – David Fells Sep 13 '12 at 05:32