Afshin Mehrabani

Migrating Git Repositories

Oct 16, 2013

Moving a Git repository from a server to another is a common situation that all developers could face with it, for example moving repositories from Bitbucket to Github or vice versa.

I wrote a shell script which help you out to move the repositories from any Git server to another, you can simply configure it and then just hit the Enter.


Ok, to get started you should clone or download this repository from Github:

After that, you should find two files, and CONFIG. We need CONFIG file to configure our migration, it contains from and to servers.

Our CONFIG file is look like this:


Each repository should be in one line, and in each line we have three variables separated by : character. Repository name, from Git server and to server. You can choose anything for name part of the config, it’s not matter.

Here you can see an example of the CONFIG file:

test:[email protected]:afshinm/test.git:[email protected]:afshinm/test.git

In above example I moved test repository from Bitbucket to Github. Please note that if in any variables you have : character, you should put a backslash before it to prevent the conflict between variables and values.

Also you can use both HTTPS and SSH urls for from or to servers but I prefer to use SSH forms (then you need to create a SSH Key and add it to both from and to servers, see this article)


After saving the CONFIG file, everything is ready for migration. Just type below command in shell and press Enter:


Then you will see a log of migration in your shell environment. Also you will notice if there are any errors in migration.

← Back to all articles