Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import Gitlab projects in Github

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)?
like image 226
Jamie Veenswijk Avatar asked Dec 01 '25 05:12

Jamie Veenswijk


1 Answers

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
    
like image 196
Yi Zhou Avatar answered Dec 03 '25 17:12

Yi Zhou