Gitlab repository mirroring

2019-01-03 12:50发布

Is it possible to have gitlab setup to automatically sync (mirror) a repository hosted at another location?

At the moment, the easiest way I know of doing this involves manually pushing to the two (gitlab and the other) repository, but this is time consuming and error prone.

The greatest problem is that a mirror can resynchronize is two users concurrently push changes to the two different repositories. The best method I can come up with to prevent this issue is to ensure users can only push to one of the repositories.

8条回答
Evening l夕情丶
2楼-- · 2019-01-03 13:27

The best option is not to use post-receive hooks, but deployments commands that perform synchronisation via rsync, using Capistrano if you like Ruby, using Shipit if you prefer Javascript (Grunt).

查看更多
家丑人穷心不美
3楼-- · 2019-01-03 13:29

A quick summary of configure mirroring repositories with GitLab and GitHub


  1. GitHub: Settings > Developer settings > Personal access tokens
    • You need enable: public_repo
  2. GitLab: GitLab project > Settings > Repository > Mirroring repositories


Push

  • Git repository URL: https://username@github.com/username/repo.git
  • Mirror direction: Push
  • Authentication method: Password
    • Password: your_token


Pull

  • Git repository URL: https://github.com/username/repo.git
  • Mirror direction: Pull
  • Authentication method: leave_empty


Official GitLab documentation

查看更多
登录 后发表回答