Migrate Git repo from BitBucket to VSTS

migrationIn this post I’ll show how Git repo can be completely transferred from BitBucket to Visual Studio Team Services.
However, this instruction will be relevant for Git repo transfer between any origins, such as GitHub, Stash, GitLab, etc.

Before migration starts, it’s important to commit and push all changes from local repositories to the current origin (which happens to be BitBucket in our example).

First of all you have to have SSH access to both source and target repos, check that you have relevant keys and config:

screen-shot-2016-11-10-at-12-37-57

Clone source repo and make local copy of all branches:

screen-shot-2016-11-10-at-13-05-22

Create target Git repo (VSTS in this example):

screen-shot-2016-11-10-at-13-07-55

Add new origin to the local repo, push everything to the new origin, remove source origin and rename new origin:

Check that in VSTS all branches and commits are available:

screen-shot-2016-11-10-at-13-14-50

screen-shot-2016-11-10-at-13-15-17

screen-shot-2016-11-10-at-13-25-32

Also you can see that tags pushing can be a problem if you use ’em:

screen-shot-2016-11-10-at-13-29-15

Now it’s time to add permissions for developers, and they can use the same ssh keys.
However, they have to delete their current local repos and clone ’em again from new origin.

It’s good idea to keep old origin (BitBucket in our example) for a while, but remove all permissions except owner (root, admin or whatever other service account).

I hope this info will be useful for you, and if you need any help feel free to use contact from on the main page.