【发布时间】:2020-10-09 20:15:00
【问题描述】:
在我的服务器上,在/home/user/git/domain.com.git/ 中,我运行了git init --bare,然后在hooks 目录和chmod +x hooks/post-receive 中创建了post-receive 文件。我使用ls -la 来验证它是可执行的。
我的post-receive 文件:
mkdir /home/USER/pub/domain.com
GIT_WORK_TREE=/home/USER/pub/domain.com git checkout -f
GIT_WORK_TREE=/home/USER/pub/domain.com git reset --hard
我从本地执行git push remotename branchname 并得到错误:
remote: fatal: You are on a branch yet to be born
它还显示:
To ssh://domain.com/~/git/domain.com.git
oldcommithash..newhash branchname -> branchname
我知道 post-receive 挂钩正在运行,因为我的 mkdir 给了我一个目录已存在错误,这是意料之中的,并且在我使用此设置的其他网站上没有问题。
git push remotename HEAD 也有这个问题,我最终想使用它来编写更简单的脚本。
【问题讨论】:
标签: git remote-server githooks