Migrated from GitHub to GitLab to use Private Repository for free

Tadashi Shigeoka ·  Sat, January 5, 2019

I wanted to use Private Repository for free, so I migrated from GitHub to GitLab.

GitLab | ギットラボ

(Prerequisites) GitLab allows free Private Repository usage

While GitHub charges for Private Repository usage, GitLab allows free Private Repository usage, and you can add unlimited collaborators for free. It’s unlimited. It’s the best.

For details, please refer to the following comparison article:

Import repositories from GitHub feature didn't work

GitLab does have an “Import repositories from GitHub” feature properly prepared.

https://gitlab.com/import/github/status

Import repositories from GitHub | GitLab

However, when I tried using it, for some reason I got the error An error occurred while importing project: Error: Request failed with status code 422 and it didn’t work.

Error Message | Import repositories from GitHub | GitLab

Create new project & push existing git repo

Since I couldn’t use GitLab’s Import repositories from GitHub feature, I performed the migration with the following flow:

  1. Create a Blank project on GitLab
  2. Change git remote of existing Git repository, git push

Create Blank project on GitLab

Create a Blank project from New project https://gitlab.com/projects/new.

Change git remote, push branches and tags

Change the remote origin from GitHub to GitLab.

Right after Create project, at https://gitlab.com/your-group-name/your-project-name, there’s a migration script like below, so execute it as shown:

Existing Git repository

cd existing_repo
git remote rename origin old-origin
git remote add origin [email protected]:your-group-name/your-project-name.git
git push -u origin --all
git push -u origin --tags

That’s all from the Gemba where I migrated from GitHub to GitLab to use Private Repository for free.