Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mirroring from Gitlab to Github

I have been using a private Gitlab instance to hold all my code. But since most of the staff that work with me now have a Github account, i would really like to get moving and mirror my Gitlab repo to Github.

My situation:

  • a server running Gitlab (Omnibus)
  • a Github account for which I'll create an organization for where me and my staff can be organized together.

I know that there is the --mirror switch in git, but I am not really sure how this is ment to work. Documentation I found online was very wonky... So it would be nice if someone could help me out. :)

like image 970
Ingwie Phoenix Avatar asked May 15 '15 20:05

Ingwie Phoenix


People also ask

Can you link GitLab to GitHub?

GitLab CI/CD can be used with GitHub.com and GitHub Enterprise by creating a CI/CD project to connect your GitHub repository to GitLab.

What is GitHub mirroring?

repository-mirroring-actionA GitHub Action for mirroring a repository to another repository on GitHub, GitLab, BitBucket, AWS CodeCommit, etc. This will copy all commits, branches and tags. ⚠️ Note that the other settings will not be copied.


2 Answers

GitLab has now an option to do this from the UI, go to the Settings->Repository of your repo:

https://gitlab.com/yourUserNameInGitLab/yourRepoName/settings/repository

Then find the option "Mirror a repository" and click on expand. What you want to do is choose the "Push" mirror direction and fill this URL:

https://[email protected]/yourUserNameInGitHub/yourRepoName.git

In the password field, you have to use a Personal Access Token (as GitHub has deprecated password access now), which you can generate here: https://github.com/settings/tokens (don't forget to enable the "repo" and "workflow" permissions when generating it)

like image 68
knocte Avatar answered Sep 23 '22 14:09

knocte


Another options is to add an additional URL to the origin:

git remote set-url --add origin [email protected]:<USERNAME>/<PROJECTNAME>.git 

When you push to origin it will push to both the original origin (gitlab) and the one added above (github).

like image 37
Kris Avatar answered Sep 23 '22 14:09

Kris