3

I've recently made a Gitlab account which I want to use as a portfolio. I've created a Github Page with some content in it. Now the problem is, I'm trying to import all my projects I've made in Gitlab to my Github account. I've searched off Google and forums, some suggested I need to make tokens, which I tried but it didn't work.

I've tried to literally import a single Gitlab repository into my Github repository with the "+" button near my profile. It didn't work with the message "No source repositories were detected at https://git.osl.frl/JVeenswijk/pfSense. Please check the URL and try again" (Yes the project is set to public) from which I believe importing from Gitlab just doesn't work properly.

So I tried it with tokens, importing and even through the Github Desktop but neither of these work for me. I find it quite strange that Github and Gitlab have such trouble of connecting to each other, from my perspective they're almost the same with the functionalities but different features.

Now the question is:

  • Is there a way to import my projects from my Gitlab to Github account?
  • Can I just create a link from a Gitlab repository and put it on my Github Page without having to login if someone clicks on that link (read-only)?
  • 1
    see this: https://stackoverflow.com/q/22265837/7923352 – eerFun Dec 13 '18 at 14:39
  • 2
    "I believe importing from Gitlab just doesn't work properly"—it's also possible that GitHub is (properly, I think) refusing to connect to a site with an invalid TLS certificate. Here's what I get when I try to clone via the URL you provided above: "fatal: unable to access 'https://git.osl.frl/JVeenswijk/pfSense/': SSL certificate problem: certificate has expired". Set yourself up with a proper one (Let's Encrypt can help you with that for free) and try again. – ChrisGPT was on strike Dec 13 '18 at 15:39
  • Alternatively, try using an SSH URL like `git@git.osl.frl:JVeenswijk/pfSense` instead (though you're likely to run into SSH key fingerprint issues there). – ChrisGPT was on strike Dec 13 '18 at 15:41
  • Okay I will try those options, thanks for your help! – Jamie Veenswijk Dec 18 '18 at 08:23

2 Answers2

12

I just successfully transferred the repository from GitLab to GitHub.

The repository in GitLab is private, which indicates that the GitHub Importer does not work, therefore, I follow below link and it works.

the instruction from GitHub official web page

Steps

  1. Create a new repository on GitHub. You'll import your external Git repository to this new repository.
  2. On the command line, make a "bare" clone of the repository using the external clone URL. This creates a full copy of the data, but without a working directory for editing files, and ensures a clean, fresh export of all the old data.
    $ git clone --bare https://external-host.com/extuser/repo.git
    # Makes a bare clone of the external repository in a local directory
    
  3. Push the locally cloned repository to GitHub using the "mirror" option, which ensures that all references, such as branches and tags, are copied to the imported repository.
    $ cd repo.git
    $ git push --mirror https://github.com/ghuser/repo.git
    # Pushes the mirror to the new GitHub repository
    
    4.Remove the temporary local repository.
    $ cd ..
    $ rm -rf repo.git
    
Yi Zhou
  • 121
  • 2
  • 6
4

You can do it. It's a feature of gitlab, mirror another repository.

The option for doing it are on project page -> settings -> repository -> mirror a repository. This option allows you both options: pulling from a remote repository, and pushing to it.

For doing what are you asking, there's the gitlab help:

To set up a mirror from GitLab to GitHub, you need to follow these steps:

Create a GitHub personal access token with the public_repo box checked.
Fill in the Git repository URL field, with the personal access token instead of a password.
For example: https://<GitHubUsername>:<GitHubPersonalAccessToken>@github.com/group/project.git.
Click the Mirror repository button.
Wait, or click the update button.

Please, check help on gitlab (https://gitlab.com/help/workflow/repository_mirroring) for more information.

Sakura Kinomoto
  • 1,784
  • 2
  • 21
  • 30
  • On Stack Overflow, if you find the answer was correct it's good to mark it as accepted answer. And if an answer is helpful, vote up it. Doing it, other users can view the better answers of the questions. – Sakura Kinomoto Dec 22 '18 at 15:28