在服务器上,/home/git/xxx/hooks/post-receive:
#!/bin/bash
cd /var/www/xxx
git pull
在服务器上,/var/www/xxx 是这样创建的:
cd /var/www
git clone /home/git/repositories/xxx.git
当我在客户端上运行“git push”时,收到以下消息:
remote: fatal: Not a git repository: '.'
有任何想法吗?
在服务器上,/home/git/xxx/hooks/post-receive:
#!/bin/bash
cd /var/www/xxx
git pull
在服务器上,/var/www/xxx 是这样创建的:
cd /var/www
git clone /home/git/repositories/xxx.git
当我在客户端上运行“git push”时,收到以下消息:
remote: fatal: Not a git repository: '.'
有任何想法吗?
如此处所述,问题在于GIT_DIR设置.为何时调用钩子。
如果您GIT_DIR在 post-receive 挂钩中取消设置,它应该可以工作:
#!/bin/bash
unset GIT_DIR
cd /var/www/xxx
git pull
根据您的评论,您希望在将更改推送到 Git 存储库时自动更新网站。试试这个:http ://www.ekynoxe.com/automated-deployment-on-remote-server-with-git/
请注意,网站根目录 ( /var/www/xxx) 本身并不是 Git 存储库;它只是保存工作树。
您缺少拉取的目录,
cd /var/www
git clone /home/git/repositories/xxx.git
上面的命令将在/var/www下创建一个新目录 为 xxx,前提是您的应用程序名称是 xxx。
现在你需要进入这个新创建的目录,比如,
cd /var/www/xxx
现在运行命令“git push”。这应该有效。
存储库文件夹应该是裸存储库。
git init --bare