这些线有什么作用?
我正在查看 http://toroid.org/ams/git-website-howto一直很好,直到我遇到这个:
$ mkdir /var/www/www.example.org
$ cat > hooks/post-receive
#!/bin/sh
GIT_WORK_TREE=/var/www/www.example.org git checkout -f
$ chmod +x hooks/post-receive
我在网上找不到 GIT_WORK_TREE
的任何文档,而且我不知道那里发生了什么。
另外,为什么他在远程 $ git init --bare
上设置不应该是 not 裸露的,因为他想在那里部署实际文件?
I was looking at http://toroid.org/ams/git-website-howto and was following along fine until I got to this:
$ mkdir /var/www/www.example.org
$ cat > hooks/post-receive
#!/bin/sh
GIT_WORK_TREE=/var/www/www.example.org git checkout -f
$ chmod +x hooks/post-receive
I can't find any doc online for GIT_WORK_TREE
and I have no idea what's happening there.
Also why does he set up on the remote $ git init --bare
shouldn't that be not bare as he want to deploy the actual files there?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
GIT_WORK_TREE
与使用
--work-tree
相同git 命令。裸存储库
您只能推送到裸存储库。因此,他执行了以下操作:
/home/git/repos/www.example.org
等位置(在服务器上)。/var/www/www.example.org
(在服务器上)。将您的 Apache/httpd 指向非裸存储库位置。
向裸存储库添加一个接收后钩子(
hooks/post-receive
, chmod +x),该钩子在收到推送时检查裸存储库(即使用GIT_WORK_TREE =/var/www/www.example.org
)。 (注意:如果您必须重新加载/重新启动服务器(例如 Ruby 应用程序),请将service SERVICE_NAME restart
之类的内容也添加到挂钩脚本中。)从您的开发计算机推送到裸机回购。裸存储库现在将自动“转发”推送到位于
/var/www/www.example.org
中的存储库。 githooks 和 MagicTM 的统一现已更新您的代码,如果您在浏览器中按 F5,您应该会看到更改。GIT_WORK_TREE
It's the same as using
--work-tree
with thegit
command.Bare Repository
You can only push to bare repositories. So he does the following:
/home/git/repos/www.example.org
(on the server)./var/www/www.example.org
(on the server).Point your Apache/httpd to the non-bare repo location.
Add a post-receive hook (
hooks/post-receive
, chmod +x) to the bare repo, which checks out the bare repository when a push is received (i.e. useGIT_WORK_TREE=/var/www/www.example.org
). (Note: If you have to reload/restart your server (Ruby apps for example) add something likeservice SERVICE_NAME restart
to the hook script as well.)Push from your development machine to the bare repo. The bare repo will now automatically "forward" that push to the repository residing in
/var/www/www.example.org
. The unison of githooks and MagicTM has now updated your code, you should see changes if you F5 in your browser.