更新站点时 git hook 出现问题
我在服务器上建立了一个网站并使用git来维护它。出于这个原因,我创建了两个 git 存储库,一个位于 $HOME/site
的裸存储库,我将其推送到其中,另一个位于 /var/www
的非裸存储库(假设是)每次进行更改时从裸存储库中提取。
为了自动更新非裸存储库,我在裸存储库中创建了更新后 git 钩子并授予了执行权限,其中包含以下内容:
#!/bin/bash
cd /var/www
git pull
但是,在每次推送到裸存储库之后我可以在我的终端上看到以下内容:
remote: fatal: Not a git repository: '.'
关于此钩子,我是否遗漏或做错了什么?
I have set up a website on a server and use git to maintain it. For this reason I have created two git repositories, a bare one at $HOME/site
to which I push and a non-bare one at /var/www
which is supposed to pull from the bare repository every time a change is made.
In order to update the non-bare repository automatically, I have created and granted executon permission to a post-update
git hook in the bare repository that contains the following:
#!/bin/bash
cd /var/www
git pull
However, after every push to the bare repository I can see the following on my terminal:
remote: fatal: Not a git repository: '.'
Is there anything I have omitted or done wrong regarding this hook?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个。在执行 git pull 命令之前,将此行添加到您的挂钩脚本中:
这将取消设置所有 GIT_XXX_YYY 环境变量。
Try this. Add this line to your hook script before you do the git pull command:
This will unset all GIT_XXX_YYY environment variables.