如何将 git 仓库同步到镜像仓库

Ric*_*icy 6 git synchronization mirror

我想将 git repo 镜像到我的本地 repo,并希望及时同步它们,我这样做了:

git clone --mirror source_url source_repo
cd source_repo
git push --mirror local_url
Run Code Online (Sandbox Code Playgroud)

现在我已经将源存储库镜像到我的本地存储库,我可以像这样克隆我的本地存储库:

git clone local_url local_repo
Run Code Online (Sandbox Code Playgroud)

但是由于源代码库正在更新,我怎么能让它们保持同步?

Ish*_*iri 1

这里有几种方法。您可以选择一个您方便的。

  1. https://softwareengineering.stackexchange.com/questions/195456/keeping-git-repositories-on- Different-hosts-in-sync中讨论的方法(编写脚本等)
  2. 将自定义挂钩添加到您的 git 存储库 - https://www.digitalocean.com/community/tutorials/how-to-use-git-hooks-to-automate-development-and-deployment-tasks
  3. 如果您使用的是 BitBucket 这样的第三方工具,他们应该为此内置解决方案或插件。例如: https: //marketplace.atlassian.com/plugins/com.englishtown.stash-hook-mirror/server/overview