Move Repository from GitLab to GitHub using Command Line

You can migrate your code from a GitLab repository to a GitHub repository with a few easy steps.

First, you have to create an empty repository on GitHub. We can do it using the GitHub API. The following command will create a new private repository with the name TestRepo.

curl -u YourGitHubUserName https://api.github.com/user/repos -d "{\"name\":\"TestRepo\", \"private\":true}"

Next, you change to the directory with the source code you want to transfer and add the newly created GitHub repository to the git configuration.

git remote add github https://YourGitHubUserName@github.com/YourGitHubUserName/TestRepo.git

Finally, you can transfer the code using the push command with the mirror attribute.

git push --mirror github

Now you have your source code on GitHub.

%d