Home > Mobile >  Mirroring GitHub to Gitlab
Mirroring GitHub to Gitlab

Time:06-09

Problem: I'm not the administrator of the Gitlab instance and the mirroring feature of GitLab doesn't work. Now I have tried to use a GitHub action to do the job. Which is failing for the same reason as in this bug report. https://github.com/SvanBoxel/gitlab-mirror-and-ci-action/issues/10

pushing to master branch at https://gitlab.com/zuedev/*********
warning: redirecting to https://gitlab.com/zuedev/*********.git/
To https://gitlab.com/zuedev/*********
 ! [rejected]            master -> master (fetch first)
error: failed to push some refs to 'https://gitlab.com/zuedev/*********'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Question: How can I resolve this? I just want to declare GitLab cold and work with GitHub.

CodePudding user response:

For me the migration feature of gitlab works just fine. I simply had to create an api-token in github and import the github projects with proper credentials to gitlab with the given token.

Regarding your error message above, it seems like you have changes in your gitlab repository remotely already, which should not be the case when you create an empty repository.

What might help is to do the following:

  • clone your github repository locally
  • add your gitlab repository as alternating remote
  • push your local repository to the alternating remote
  • Related