我想将 Git 仓库镜像到本地仓库,并希望及时同步它们,我像这样做:
git clone --mirror source_url source_repo
cd source_repo
git push --mirror local_url
现在我已经将源代码库镜像到本地代码库,我可以像这样克隆我的本地代码库:
git clone local_url local_repo
但是由于源代码库正在更新,我该如何保持它们同步?
我想将 Git 仓库镜像到本地仓库,并希望及时同步它们,我像这样做:
git clone --mirror source_url source_repo
cd source_repo
git push --mirror local_url
git clone local_url local_repo
但是由于源代码库正在更新,我该如何保持它们同步?
git remote update
命令进行同步。cd REPO
git remote update
git-sync-mirror
A simple synchronization container image for git repositories over HTTPS
Features:
- Authentication with https tokens
- If needed, use a different HTTPS Proxy for source and destination
- TLS-Trust On First Use: Seamlessly run this container behind a https scanning proxy
- Skip certificate checks (don't do that)
- Configure time to sleep between synchronization attempts
Usage
$ docker run \ --rm \ --env SRC_REPO=source \ --env DST_REPO=destination \ --env SLEEP_TIME=30s \ enteee/git-sync-mirror
Note: The container is designed for synchronization over https with supported authentication using access tokens. For example replace source with https://github-user:github-access-token@github.com/Enteee/git-sync-mirror.git
这里有几种方法。您可以选择方便的一种。
我多年来一直使用以下方案:
在一个远程服务器(server1)上为我的分布式客户端创建一个或多个主git存储库。所有非本地用户(在serverX上)都会将所需的存储库克隆到本地并将更新推送到主存储库。
在另一个远程服务器(server2)上,我将主存储库克隆为镜像。然后我设置了一个cron作业定期运行“cd REPO; git remote update”。该远程服务器目前正在Digital Ocean上设置,并且我已经安排了每周备份。过去,我曾在至少两个不同的远程服务器上镜像主存储库以确保安全性。
Local repository pushes to remote repository "A"
Remote repository "A" pushes to remote repository "B"
git push --all --force
现在部署的远程仓库“B”始终与中央远程仓库“A”自动保持最新。