git - 在 git 中链接两个存储库
问题描述
我们有一组 git 存储库,用于开发我们的产品。这些存储库在 bitbucket 或 gitlab 中进行管理,并托管在本地或云端。对这些 repo 所做的更改需要定期(比如每月一次)传播到 github 中托管的一组公共 repo。这个要求是为了支持我们的 beta 计划,我们在公开之前测试更改(使其成为 GA)。是否有任何标准模式可用于此目的?
解决方案
Clone the Bitbucket repository to your local machine:
$ git clone --mirror ssh://git@bitbucket.org:your_name/your_repo.git
Then you basically have to run these two commands every month:
$ git remote update --prune
$ git push --mirror git@github.com:your_name/your_repo.git
Linux and Cron
If you have a Linux machine/Linux server/WSL edit your crontabs:
$ crontab -e
Add this crontab:
@monthly git -C <local_repo_path> remote update --prune && git -C <local_repo_path> push --mirror git@github.com:your_name/your_repo.git
macOS and Cron
Automating tasks using Cron is very similar to the way it's done in Linux, follow this guide to get started.
Windows and Scheduled Task
I am not very familiar with Schtasks, but I this is how you would automate the task:
> schtasks /create /tn git-mirror /tr git -C <local_repo_path> remote update --prune && git -C <local_repo_path> push --mirror git@github.com:your_name/your_repo.git /sc weekly /d MON /ru "System"
推荐阅读
- django - Django 过滤 timedelta 错误:TypeError: expected string or bytes-like object
- angular - 新的 Draggable 在拖动后重置滚动
- javascript - 选中复选框时如何使用 id 显示和隐藏
- php - 解析错误:第 7 行 C:\xampp\htdocs\script\includes\application_top.php 中的语法错误、意外的 ','、期望 ')'
- javascript - 如何在 Angular 2 项目中使用脚本标签
- javascript - 无法使用 react-redux 更新状态
- bash - bash循环覆盖下一个文件
- jsf - 用于 p:selectOneMenu 转换器的应用范围 bean
- java - 在应用中间安装apk - Android Studio
- android - 如何显示所有聊天 Mesibo Android SDK