I will be showing how I migrated a repository from GitHub to GitLab. There are two methods;
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
- Choose the import project option
- choose the GitHub option
- It will show the option of Authorization from GitHub.
- you can import all repositories or choose the repository to be migrated. Also, there is an option of importing issues pull request events.
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>
- Create a new project in GitLab, and choose the create the blank project option
- Give a project name and click create project.
- 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