出现了使用git push时引起500服务器错误的问题。根据服务器错误,这似乎是一个文件权限问题。每次我从本地机器执行git push时,文件的所有权都会发生改变。
为了让它再次正常工作,我必须进入public_html文件夹并执行chown potter.potter * -R
有人可以帮帮我吗?下面是我设置的方式...
我在我的网站开发服务器上的/home/username/gitrepos目录下设置了一个名为potter.git的存储库。
ssh root@potter.com
git config --global user.email "harry@potter.com"
git config --global user.name "harry"
在/home/potter/gitrepos目录下
mkdir potter.git
cd potter.git
git init --bare
设置钩子以允许部署
cd hooks
pico post-receive
将以下内容输入到post-receive钩子中以允许部署。
#!/bin/bash
#
docroot="/home/potter/public_html"
while read oldrev newrev ref
do
branch=`echo $ref | cut -d/ -f3`
if [ "master" == "$branch" ]; then
git --work-tree=$docroot checkout -f $branch
fi
done
将 post-receive 变成可执行文件。
chmod 755 post-receive
在 .bash-profile 中设置工作目录
# GIT
export GIT_DIR=/home/potter/potter.git
export GIT_WORK_TREE=~/public_html
现在在我的本地机器上,我按照以下方式设置了远程连接:
git remote add website ssh://root@potter.com/home/potter/potter.git
我进行推送的方法如下:
git push website master