混帐后收到结帐远程机器? [英] git post-receive checkout to remote machine?
问题描述
如果您添加下面的脚本作为挂钩/后接受
勾到裸Git仓库 foo.git
:
If you add the following script as a hooks/post-receive
hook to a bare git repository foo.git
:
#!/bin/sh
GIT_WORK_TREE=/bar git checkout -f
然后每当有人推到库目前的状态将在目录更新栏
。
这需要栏
和 foo.git
来在同一台机器上。
This requires bar
and foo.git
to be on the same machine.
什么是修改它的最简单的方法,这样结账在远程机器上进行(例如巴兹:/条
)?
What's the easiest way to modify it so that the checkout is made on a remote machine (say baz:/bar
) ?
的一种方法将是:
#!/bin/sh
GIT_WORK_TREE=/tmp/bar git checkout -f
rsync ... /tmp/bar baz:/bar
有没有更好的办法?也许并不需要中间临时目录? (如果没有什么是正确的选项传递给rsync的,这样生成的目录是张玉峰以直接签出?)
Is there a better way? Perhaps not requiring an intermediate temp directory? (If not what are the correct options to pass to rsync such that the resulting directory is indentical to being checked out directly?)
推荐答案
GIT_WORK_TREE = /条
表示栏
是混帐回购协议。
GIT_WORK_TREE=/bar
means that bar
is a git repo.
如果栏
是在远程端一个混帐回购协议,那么它可以从一个裸回购拉 bare_bar.git
(另在远程端),您可以向其中推到。
If bar
is a git repo on the remote side, then it can pull from a bare repo bare_bar.git
(also on the remote side), to which you can push to.
在换句话说,你的后接受
挂钩将推动通过ssh来bare_bar回购和后接受
对裸回购钩子将触发从实际回购的拉栏
:见的从生产文件夹。
In other words, your post-receive
hook would push to bare_bar repo through ssh, and a post-receive
hook on that bare repo would trigger the pull from the actual repo bar
: see "Creating a git repository from a production folder".
我倒是preFER,保持不含任何git的迪尔斯的(甚至是混帐包本身理想情况下)远程服务器的解决方案
I'd prefer a solution that keeps the remote server free of any .git dirs (and even the git package itself ideally)
在这种情况下,当前的后收到钩和的rsync
命令似乎是唯一的出路的递增的复制新的数据到远程工作树。
In that case, your current post-receive hook and its rsync
command seems to be the only way to incrementally copy new data to a remote working tree.
这篇关于混帐后收到结帐远程机器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!