Antoine Neveux

Yet another blog about stuff.

Migrating a Git repository

Hi guys!

Just a real quick article explaining how to migrate a git repository from one server to another.

This is a pretty simple process, but you still have to consider a couple of things: you want all your remote branches to be migrated, as well as all your tags. And as any developer, you don’t want to spend time on it…

There are lots of techniques you can find on the internet… People sharing commands you can run, and I must admit approximately everything will do the trick… But here’s the most effective and simple way I found:

  • Step 1: retrieve the repository you want to migrate. Simple as: git clone --bare <url-of-the-repository>

Please note the --bare parameter, which allows to retrieve all the data of the repository, including tags and branches, without requiring you to do anything…

  • Step 2: from that repository you retrieved, send the content to the new one: git push --mirror <url-of-the-new-repository>

This time the --mirror will do the trick of pushing everything…

That’s all folks!

Now I simply suggest you clean up your workstation by removing the old repository, but otherwise the migration is ok :)

Have a good day!

Newer >>