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:
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. :)
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.
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.
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)
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).
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