Sync Multiple Remote Git Repositories
You have a git repository (repoA) as origin, which you only pull from. Sometimes the repoA is in the intranet and not accessible from the internet. You want to create a mirrored repository (repoB) in your local network for the convenience.
- Clone the repoA in local (repoL):
git clone --mirror remote.in.intranet:repoA repoL cd repoL- Add a remote repository that is pushed only:
git add remote --mirror=push repoB remote.in.local.network:repoB git push repoB
That’s it. To sync them:
git fetch --baregit push repoB
Will pull all refs, branches, and tags from repoA and push all of them to repoB.
Thanks to the stackoverflow discussion.
リモートにある複数の Git レポジトリを sync したいときにどうするか、という話。