设置本地git服务器与远程同步

时间:2019-07-29 18:43:45

标签: git github clone git-clone

我需要一个本地git服务器(裸机),它可以自动与目标远程服务器同步。 喜欢:

(clone1) --|                                   |-- (remote1.git)

..       --|                                   |-- ...

(cloneN) --|       <==> (local.git) <==>       |-- (remoteM.git)

2 个答案:

答案 0 :(得分:1)

您不能那样做。如果要从远程存储库中提取更改,则必须发出git pull(origin)命令: -https://git-scm.com/docs/git-pull -https://www.quora.com/What-are-the-differences-between-git-pull-git-pull-origin-master-and-git-pull-origin-master

如果要将本地分支推送到远程存储库,则必须使用git push: -https://www.edureka.co/community/33214/git-push-vs-git-push-origin -https://git-scm.com/docs/git-push

您可以指定要与之同步的遥控器。默认值为原点。

分支机构通常不会自行推/拉,因为有时您需要解决冲突

答案 1 :(得分:0)

Git并不是每隔一段时间都基于pull内容。
一种解决方法是添加一个调度作业(在cloneX上),每隔几分钟抓取/拉出

如果您使用的是Unix,另一种选择是使用https://myrepos.branchable.com来更新所有存储库,并再次执行预定的任务或作业。

基本上,您需要自己进行拉动,因为git不能这样工作。

其他选项:

阅读这篇优秀的博客文章:

https://moox.io/blog/keep-in-sync-git-repos-on-github-gitlab-bitbucket/