On my server, in /home/user/git/domain.com.git/
, I ran git init --bare
, then created post-receive
file in hooks
dir & chmod +x hooks/post-receive
. I used ls -la
to verify it is executable.
My post-receive
file:
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
I execute git push remotename branchname
from local and get the error:
remote: fatal: You are on a branch yet to be born
It also shows:
To ssh://domain.com/~/git/domain.com.git
oldcommithash..newhash branchname -> branchname
I know the post-receive hook is running because my mkdir
gives me a directory already exists error, which is to be expected and causes no problems on my other sites using this setup.
I also have this problem with git push remotename HEAD
which is what I want to use, ultimately, for simpler scripting.