简体   繁体   English

当远程仓库发生变化时自动同步本地仓库

[英]Automatically sync a local repo when changes occur in remote repo

Say we have a remote repo 'HelloWorldRemote' and I already cloned a local repo from the same, say 'HelloWorldLocal'.假设我们有一个远程仓库“HelloWorldRemote”,我已经从同一个仓库克隆了一个本地仓库,比如“HelloWorldLocal”。 Is it possible to set up an automatic git sync HelloWorldLocal with changes from HelloWorldRemote whenever any new changes/commits happen on HelloWorldRemote?每当 HelloWorldRemote 上发生任何新的更改/提交时,是否可以设置自动 git 与来自 HelloWorldRemote 的更改同步? Is this possible in either GitHub or GitLab?这在 GitHub 或 GitLab 中是否可能?

Yes, you can use a git-hook on the remote to trigger some action on your local machine, but that would require:是的,您可以在遥控器上使用 git-hook 来触发本地计算机上的某些操作,但这需要:

  • a process running locally that listens for a network message, and does some carefully-crafted automatic git pull that handles any and all errors that will come up一个本地运行的进程,它侦听网络消息,并执行一些精心设计的自动git pull ,以处理将出现的任何和所有错误

  • exposing that process to the remote git server, via ssh/proxy/etc通过 ssh/proxy/etc 将该进程暴露给远程 git 服务器

  • configuring a git-hook to use that ssh/proxy/etc tunnel to tell your local process to do its thing配置 git-hook 以使用该 ssh/proxy/etc 隧道来告诉您的本地进程执行其操作

It would be better to simply use git as intended: git fetch manually, and see for yourself what has changed.最好按预期简单地使用 git: git fetch手动获取,并亲自查看发生了什么变化。 Or, if your local repo is literally just a read-only copy of the upstream repo that you never commit to, cron a git pull every X minutes.或者,如果您的本地存储库实际上只是您从不提交的上游存储库的只读副本,则每 X 分钟 cron 一次git pull

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM