Yes you can, you can share the same key between them both (ssh key) or create a new one per git server.
On GitHub.com, navigate to the main page of the repository. Under your repository name, click Settings. Under "Danger Zone", click Transfer. Read the information about transferring a repository, then type the name of the user or organization you'd like to transfer ownership of the repository to.
You can transfer those (simply by adding a remote to a GitHub repo and by pushing them)
git remote add github https://[email protected]/yourLogin/yourRepoName.git
git push --mirror github
The history will be the same.
But you will loose the access control (teams defined in GitLab with specific access rights on your repo)
If you facing any issue with the https URL of the GitHub repo:
The requested URL returned an error: 403
All you need to do is to enter your GitHub password, but the OP suggests:
Then you might need to push it the ssh way. You can read more on how to do it here.
See "Pushing to Git returning Error Code 403 fatal: HTTP request failed".
This is very easy by import repository feature
Login to github.com
,
Side of profile picture you will find +
button click on that then there will be option to import repository
.
you will find page like this.
Your old repository’s clone URL is required which is gitlab repo url in your case.
then select Owner and then type name for this repo and click to begin import button.
If you want to migrate the repo including the wiki and all issues and milestones, you can use node-gitlab-2-github and GitLab to GitHub migration
If you have MFA enabled on GitLab you should go to Repository Settings/Repository ->Deploy Keys and create one, then use it as login while importing repo on GitHub
With default Github repository import it is possible, but just make sure the two factor authentication is not enabled in Gitlab.
Thanks
For anyone still looking for a simpler method to transfer repos from Gitlab to Github while preserving all history.
Step 1. Login to Github, create a private repo with the exact same name as the repo you would like to transfer.
Step 2. Under "push an existing repository from the command" copy the link of the new repo, it will look something like this:
[email protected]:your-name/name-of-repo.git
Step 3. Open up your local project and look for the folder .git
typically this will be a hidden folder. Inside the .git
folder open up config
.
The config file will contain something like:
[remote "origin"]
url = [email protected]:your-name/name-of-repo.git
fetch = +refs/heads/:refs/remotes/origin/
Under [remote "origin"]
, change the URL to the one that you copied on Github.
Step 4. Open your project folder in the terminal and run: git push --all
. This will push your code to Github as well as all the commit history.
Step 5. To make sure everything is working as expected, make changes, commit, push and new commits should appear on the newly created Github repo.
Step 6. As a last step, you can now archive your Gitlab repo or set it to read only.
You can use the following commands:
cd existing_repository
git remote rename origin old-origin
git remote add origin <yourRepository.git>
git push -u origin --all
git push -u origin --tags
If an error occurs, you can try to force the push using the -f
command, type like this:
git push -u -f origin --all
git push -u -f origin --tags
This would be the path recommended by GitLab to import an existing repository on GitHub, however, if you change the <yourRepository.git>
link to the repository link on GitHub it is possible to go the other way, transferring from GitLab to GitHub. In practice, you create a new origin and force a push of everything.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With