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?

  • This pull request cannot be merged. You will need to resolve conflicts to be able to merge
  • Why was there an Atlassian icon in my shell when I pushed a commit?
  • Removing/undoing a merge on Sourcetree
  • Git is failing to Stage, or commit with SourceTree in a Windows network environment
  • SourceTree and Stash: Unable to get local issuer certificate
  • Migrate single repository from one Atlassian stash server to another server and maintain all data
  • 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.

  • local git check-ins — hide from main repository?
  • git required password on every push
  • Git Shows Random Files as Modified After Clone; Can't Discard Them
  • Remove files from local git but not from remote
  • If some one knows my Github username and email, can they commit or push the files of my project?
  • Mac OS X 10.10 merge tool git bugs
  • 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.