3 useful advices while migrating from GitHub to GitLab

Viacheslav Starikov
2 min readJan 2, 2019

--

Half a year ago I tried to migrate my private repo from GitHub to GitLab but I got an error while the importing process. Maybe the error occurred because of the wiki pages in my repo on GitHub, I don’t exactly know. But today everything went well and I migrated!

1. Use GitLab’s import feature

You can import your GitHub repository manually but in this case some of your data that is not a part of git repository may be lost. For example, wiki pages.

While allowing GitLab to import your project it will try to import not only git repo but other things like wiki pages, etc.

So, to import your project go to GitLab’s dashboard and press a green button “New Project”, then select the “Import project” tab, press “GitHub” button and follow the GitLab’s instructions.

2. Make a backup just in case

To make a backup of your git repository with all the branches just type this single command:

git clone --bare https://github.com/user/repo.git

It will create a directory with the .git extension. Then you can restore all the repo with all the branches out of this backup (directory).

3. Change local repo origin URL

You don’t have to remove the project’s directory and clone the repo again to make it work with GitLab. Just change the origin URL!

So, go to your project’s folder and type:

git remote set-url origin https://gitlab.com/user/repo.git

Then to verify that it took effect type this command:

git remote -v

And you will get a list of new origin URLs. After this you can continue working with your repository inside the old project directory pulling and pushing the changes but now to and from GitLab 😼

So, that’s it and happy coding!

--

--