Migrating a code repository but retaining committing history


​Here, we aim to move a code repository from platform A to platform B completely, but keep the commiting history at the same time. It works for the code repository platforms using git like Github.


We take migrating a code repository from Gitlab (source platform) to Github (destination platform) as an example.

Create a new project on the destination platform

On Github, we create a new empty project with the same name as the source repository (It also works for a new name).

{% note danger %} Do not check Add a README file, Add .gitignore, and Choose a license. {% endnote %}

Clone the code repository from the source platform

Clone the code repository which you want to move from the source platform to a local folder, using the following git code, with the parameter --bare.

git clone https://gitlab.com/abc/xyz.git --bare

Push the code repository to the destination platform

After cloning, push all branches and objects of the code repositoty to the destanation platform, using the following code, with the URL of the destination repository.

cd xyz.git
git push https://github.com/abc/xyz.git --all

Push the tags to the destination platform

Finally, redo the similar operation, pushing the local repository tags to the destination platform using the parameter --tags.

git push https://github.com/abc/xyz.git --tags

After these operations, the code repository has been moved from source platform to he destination platform, together with the commiting records.