简体   繁体   中英

How to have synchronize two git bare repositories?

Is possible to clone a git bare repo as a new bare repo ? for example:

  • git init --bare mainRepo.git

Then in a remote server:

  • git clone --bare xxx@server:/path/mainRepo.git repoReplica.git

And then with a cron job send changes from repoReplica.git to mainRepo.git, so I can have 2 teams working, one directly with mainRepo.git and the second with repoReplica.git

Is it possible ? and How ?

It is possible, but I would suggest for your synchronisation process to:

  • not use cron
  • use a post-receive hook which can then push what has been receive to the other repo
  • limit the synchronization to one branch
  • use different branches

Meaning:

  • repo1 would push master to repo2 as master_fromrepo1

     git push repo2 master:master_fromrepo1 
  • repo2 would push master to to repo1 as master_fromrepo2

     git push repo1 master:master_fromrepo2 

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