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?

  • Vertical line guide at 80 characters for Bitbucket
  • Migrate single repository from one Atlassian stash server to another server and maintain all data
  • Creating atlassian stash repo using rest and powershell
  • Why was there an Atlassian icon in my shell when I pushed a commit?
  • Is there a way to push a bitbucket repo to a development website easily?
  • Programmatically triggered Bamboo plans
  • 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://git@mystashurl.com:8080/Stash/Project.git MyGithubProject
    cd MyGithubProject
    git remote set-url origin git@github.com:MyGithubOrg/MyGithubProject.git
    git push --mirror origin

    And it retained all the expected history, including branches.

  • Unable to Clone Gerrit Repository
  • Files get committed with the wrong file encoding
  • Why does “git cat-file -p HEAD^2” fail?
  • hudson cannot fetch from git repository
  • Is they a way to set push.default to `current` only for the current push
  • git and Cygwin Paths with SourceTree
  • 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:

    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.

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

    Git Baby is a git and github fan, let's start git clone.