Migration from Gitlab zu Github

I have to migrate my code repositories form Gitlab on premise to Github Cloud. The built in migration function from Github does not work because Gitlab on premise is not reachable from outside. Furthermore my Jenkins Buildserver must be able to fetch the code from Github. How can I solve that?

Comments

I just had the same problem, I wanted to rate multiple stars and only one is displayed, very sorry. I have already created a new challenge, I hope I find a solution..
Anna Lackinger - Wed, 12/15/2021 - 08:31 :::
2 answers

It's simple, just follow the steps:)

1. Inside your GitHub team page, create an empty private repo with the same name of Bitbucket/GitLab
repo that you want to transfer.

2. Copy your newly created repo link, either in HTTPS or SSH.
For example, git@github.com:team-name/repo-name.git (SSH type)

3. Inside your local project folder, change the remote URL under.git/config ‘s file to your copied
GitHub's
one. The content looks similar as follows. [remote "origin"]
url = git@github.com:team-name/repo-name.git
fetch = +refs/heads/*:refs/remotes/origin/*

4. Do a git push: git push --all . It will push all codes and commit history on your newly GitHub
repository.

5. Done. After that, when we push new commits, it will push to GitHub only.

6. The Bitbucket/GitLab repo now can be archived to ‘Read-only’ mode.

You can do the migration with the git cli:
1) Mirror the Gitlab repo to your local machine (git clone --mirror )
2) Move to your repo (cd )
3) Remove remote repo (git remote remove origin)
4) Create Repo in github via web interface
5) Add new remote repo (git remote add origin )
6) Push to github (git push origin --mirror)

For the Jenkins integration you can use ssh deploy keys:
1) Create a deploy key (ssh-keygen -t rsa)
2) Add public key to Github (Settings → Deploy Keys)
3) Add private key to Jenkins (Add credentials → ssh username with private key)
4) Select the github repo ssh url and the created credentials within the Jenkins job

Comments

After some research I found a description here https://docs.github.com/en/actions/migrating-to-github-actions/migrating..., but your steps are much simpler and clearer, thanks for sharing!

Anna Lackinger - Wed, 12/15/2021 - 08:30 :::

Thanks for bringing up this useful case. I found the solution for the opposite case GitHub to GitLab as well :-) https://linuxkamarada.com/en/2021/06/25/how-to-migrate-projects-from-git...

Parinaz Momeni ... - Tue, 12/21/2021 - 23:28 :::