用git hook更新网站的问题 [英] Problem with git hook for updating site

查看:56
本文介绍了用git hook更新网站的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在服务器上建立了一个网站,并使用git对其进行维护.因此,我创建了两个git存储库,一个在$HOME/site推送的裸仓库,一个在/var/www推送的非裸仓库,应该在每次进行更改时从裸仓库中提取.

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.

为了自动更新非裸仓库,我已经在包含以下内容的裸仓库中创建了 git钩子并将其授予执行者权限:

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?

推荐答案

尝试一下.在执行git pull命令之前,将此行添加到钩子脚本中:

Try this. Add this line to your hook script before you do the git pull command:

unset $(git rev-parse --local-env-vars)

这将取消设置所有GIT_XXX_YYY环境变量.

This will unset all GIT_XXX_YYY environment variables.

这篇关于用git hook更新网站的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆