简体   繁体   中英

How to sync all branches of two repositories (one in github and one in gitlab) preventing merge conflicts?

Repository X.git is in gitlab with all development artifacts and respective branches I create Y.git in github using the following approach In a common server I do a mirror of gitlab

git clone --mirror http://gitlabserverdomain/user/X.git
cd X.git
git remote add githubrepoalias https://githubserverdomain/Y.git
git push -f --tags githubrepoalias refs/heads/*:refs/heads/*

Now I want to enable users to use either repositories for sometime and would like to sync either commits

These commits should not cause merge conflicts.

How do I do achieve the objective?

I see no way to prevent conflicts between changes done in GitHub and other changes done in GitLab. Try using hooks on the servers directly to minimize it.

Everything is possible :)

You just need to to somehow:

  • define git fetch-ing both-ways
  • make sync interval as short as possible (eg using web-hooks to trigger sync as soon as there is a new commit)

I've just tested with GitLab mirroring functionality: https://docs.gitlab.com/ee/workflow/repository_mirroring.html

I've defined both Push and Pull rules pointing to a GitHub repo, and it worked - changes are synchronised both ways.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM