Short tip: Migrate Git repository with history

Recently, I had to migrate a bigger amount of git repositories from one software to another provider. One requirement was to copy the whole project including commit history and tags. Fortunately, it was easy to automate this process.

First of all the former repository needs to be cloned – if not done, yet:

$ git clone <URL>

Created tags are read like this:

$ git fetch --tags

If you leverage multiple branches, check-out all branches that need to be copied once:

$ git checkout <branch>

Afterwards, remove the remote server and add the new server:

$ git remote rm origin
$ git remote add orgin <URL>

Tags and commit history is copied with these two commands:

$ git push --tags
$ git push origin --all

Sharing is caring

Leave a Reply