DEV Community

Cover image for Migrating repository from github to gitlab
Olawale Adepoju for AWS Community Builders

Posted on • Originally published at dev.classmethod.jp

Migrating repository from github to gitlab

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.

  • Log in to your GitLab, and create a new project

Image description

  • Choose the import project option

Image description

  • Choose the GitHub option

Image description

  • It will show the option of Authorization from GitHub.

Image description

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

Image description

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?

  • Clone the GitHub repository you want to migrate. use
git clone --bare <GitHub URL>
Enter fullscreen mode Exit fullscreen mode

Image description

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

Image description

  • Give a project name and click create project.

Image description

  • Push the cloned repository to GitLab.
git push --mirror <GitLab URL>
Enter fullscreen mode Exit fullscreen mode

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

Image description

How did I solve it?
Go to project: "Settings" β†’ "Repository" β†’ "Expand" on "Protected branches" and click on unprotect.

Image description

Now the GitHub repository is migrated successfully to GitLab

Image description

Top comments (2)

Collapse
 
jordantylerburchett profile image
Jordan-Tyler Burchett

Nice tutorial!

Collapse
 
jatinmehrotra profile image
Jatin Mehrotra

Classmethod <3