git post-receive无法正常工作 [英] git post-receive not working correctly

查看:581
本文介绍了git post-receive无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下问题。我已经将'post-receive'更新为cd到某个目录中,然后将回收部署到像这样部署它:

I have the following problem. I have updated the 'post-receive' to cd into a certain directory and then pull the repo in to deploy it like so:

#!/bin/bash
cd /var/www/site
git pull origin master

然而,无论何时我在本地机器上执行'git push origin master',我都会得到以下结果:

However whenever I do 'git push origin master' on my local machine I get the following:

Counting objects: 5, done.
Delta compression using up to 2  threads.
(etc..)
remote: fatal: Not a git repository: '.'

然而,当我手动cd到 / var / www / site 并执行 git pull origin master

Yet when I manually cd to /var/www/site and do git pull origin master it works brilliantly.

推荐答案

使用未设置的GIT_DIR如下

Use unset GIT_DIR as following

#!/bin/bash
cd /var/www/site || exit
unset GIT_DIR
git pull origin master
exec git-update-server-info

您可以在此处查看有关 GIT_DIR 的更多信息。
Git爱环境

You can see more information about GIT_DIR here. Git Loves the Environment

这篇关于git post-receive无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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