We have:
- Remote repository with some project.
- Several remote repositories, which I want to synchronize with previous one.
When something pushed in first project (1), I need to pull these changes to other remote repositories (2).
I can pull from first repo and push to destination repositories.
What is the simplest way to do this ?
Thanks.
You could clone a new bare mirror repository from the upstream repository that you have no control over, e.g. with:
(In fact,
--mirrorimplies--bare, so--bareisn’t strictly necessary.) The--mirroroption says that rather than just take the local branches from the remote and make them remote-tracking branches, git should mirror all the branches from the remote repository with the same names.Then, you can set up a frequent cron job that runs the following commands in that repository:
This assumes that you’ve added
repo1andrepo2as remotes, and that they point to bare repositories that you’re only wanting to use as mirrors. (The latter requirement is because you’re using--force, so if other people are pushing their work torepo1orrepo2, it’ll get overwritten by the automated mirror pushes.)