How To Migrate From GitLab To GitHub

GitLab and GitHub are competing source code management products based on Git.

Using source control, you can check all of the code changes made to projects and roll them back in the event of issues. The fact that both platforms let you see the history of a project makes it easier to understand why decisions were made, even years later.

One of the main reasons users preferred GitLab over GitHub was because the former allows users to host their own private repositories for free. On the other hand, GitHub only allows private repos for paying customers.

This has changed now. GitHub recently announced that it’ll provide free private repositories for individual users. “Teams on GitHub can create unlimited private repositories for free.“

This has given many users the incentive to migrate their projects to GitHub. If you’re also considering relocating from GitLab to GitHub, you’re at the right place. This Nira guide will break down the steps to migrate your GitLab repository to GitHub without losing commit history.

Method 1: Using the GitHub Repository Importer Tool

Thanks to GitHub‘s importer tool, you can easily migrate your project hosted on another version control system like GitLab and automatically import it to GitHub. 

Here’s how to go about it:

  1. In the upper-right-hand corner of any page, click +. Follow this up by clicking on Import repository.
  2. Under the Your old gitlab repository’s clone URL option, type the URL of the project you want to import. Screenshot of GitHub repository importer tool with box highlighted where you type URL of your old repository's clone URL
  3. Select either your personal account or an organization to own the repository. Once that’s done, type a name for the repository on GitHub.
  4. Next, specify whether the new repository will be public or private. You can check out this article to learn more about repository visibility. Box where you specify if you want your new repository to be public or private
  5. Click on Begin import.
  6. If your old project was password-protected, type the login information for that specific project. Select Submit.
  7. You may also have to choose the project you want to import if you have multiple projects hosted at your old project’s clone URL. If that’s the case, select the right project and click Submit.

You will receive an email when the repository has been completely imported, hence finishing the migration from GitLab to GitHub.

Note: For projects containing files larger than 100 MB, you have to decide whether you want to import the large files using Git Large File Storage. If yes, click Continue.

While using the GitHub Repository Importer tool is undoubtedly the easiest way to migrate from GitLab to GitHub, it may be unsuitable in certain cases. This applies especially when your existing code is hosted on a private network, meaning the Importer Tool won’t have access to the code. Here, you will have to import using the command line for Git repositories to migrate your project. Alternatively, you can use an external source code migration tool for projects imported from other version control systems.

Method 2: Using the Command Line

Before we get down to the steps, make sure you know your GitHub username and the clone URL for the external repository.

The following is how you import a Git repository using the command line. 

  1. Create a new repository on GitHub. This will be the new repository where you will import your external git repository.
  2. Make a “bare“ clone of the repository using the external clone URL on the command line. Doing this will create a full copy of the data (without a working directory for editing files) and deliver a clean export of all the old data.

$ git clone –bare

# Makes a bare clone of the external repository in a local directory

3. Next, push the locally cloned repository to GitHub using the ‘mirror‘ option. This will ensure all references (tags, branches) get copied to the imported repository.

$ cd repo.git

$ git push –mirror

# Pushes the mirror to the new repository on

4. Remove the temporary local repository.

$ cd ..

$ rm -rf repo.git

And that’s it! Following the above steps will enable you to import your Git repository using the command line. While this method works for instances where the GitHub Importer Tool is unsuitable, it still doesn’t migrate Pull Request and Issues Data. If this is important to you, there is a third method where you can use a NodeJS app to migrate from GitLab to GitHub.

Method 3: node-gitlab-2-github 

As mentioned, Node GitLab to GitHub migrates Issues, Milestones, and Pull Requests from GitLab to GitHub. If this sounds interesting to you, you can check out the step-by-step breakdown here.

Why Migrating From GitLab the GitHub Makes Sense

Now that we’ve covered the steps, we also wanted to briefly touch on the topic of the advantages of migrating from GitLab to GitHub. This will help you understand the benefits you’ll get and why this move would make sense for you.

Let’s take a look.

Modern, Uncomplicated User Interface

Over the years, GitHub has significantly improved its interface, making it much more modern. 

It does a much better job presenting code and offers faster and smoother navigation. You can click through code to get to function definitions or declare a variable to make open source projects more accessible. Everything’s simpler.

Easy and Faster Project Import to GitLab

As already discussed, importing a project into GitHub is easier than ever, thanks to its Importer tool. You can migrate your entire project by simply providing your previous repository’s clone URL, adding a new name, and deciding whether you want to make your repo private or public.

You will need to authenticate the import yourself. If you get the error .gitlab-ci.yml, you may have copied the wrong URL. So be careful when typing the URL. 

Continuous Integration/Continuous Deployment

GitLab’s shared runners for CI/CD pipelines can be set up for automatic testing and deployment, among other things. You can always use the Jupiter file to reference before starting a new project.

GitHub Workflows ensures you don’t lose this functionality, while simultaneously making the setup very straightforward and simple. You can find all various ready-to-use GitHub Action in the Marketplace.

But the main advantage of GitHub is its community and open source approach. Users use the tool to solve their needs and open-source the code they write in the process, which can come in handy for other users.

Helpful Posts to Navigate GitLab and GitHub

If you enjoyed this piece and want to explore the fascinating world of GitLab further, we recommend checking out some of the other blog posts we’ve created to help developers.

We’ve also covered GitHub’s journey to becoming a $2 billion company before finding a home in Microsoft in detail, where we break down each significant milestone. You can read about it here.

Incredible companies use Nira

Every company that uses Google Workspace should be using Nira.
Bryan Wise
Bryan Wise,
Former VP of IT at GitLab

Incredible companies use Nira