i tried migrating repository from github to gitlab

2022.11.24

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

I will be showing how I migrated a repository from GitHub to GitLab. There are two methods;

Option 1

Firstly you can do it on the console by going to GitLab and authenticating your GitHub credential there and you will be able to import all the repositories you want on GitLab.

  1. Log in to your GitLab, and create a new project

  1. Choose the import project option

  1. choose the GitHub option

  1. It will show the option of Authorization from GitHub.

  1. you can import all repositories or choose the repository to be migrated. Also, there is an option of importing issues pull request events.

Option 2

The second option, let's say your GitHub is in a private network and you want to take one repository and push it to GitLab, where GitLab is on some other network or hosted in some other cloud environment. How do you migrate in this case?

  1. Clone the GitHub repository you want to migrate.

use git clone --bare <GitHub URL>

  1. Create a new project in GitLab, and choose the create the blank project option

  1. Give a project name and click create project.

  1. push the cloned repository to GitLab.

git push --mirror <GitLab URL>

Error Alert: while I push to GitLab I encountered an error

How did I solve it?

Go to project: "Settings" → "Repository" → "Expand" on "Protected branches" and click on unprotect.

 

 

Now the GitHub repository is migrated successfully to GitLab