A small guide how I've set up my git environment to automatically publish my website after a push:
On the remote Server I initialized a new bare repo with a workdir where my homepage should be found:mkdir balpage.git cd balpage.git git init --bare git config core.worktree /var/www/yii/balpage git config core.bare false git config receive.denycurrentbranch ignoreAnd the little trick is adding a post-receive hook:
vim hooks/post-receiveand add the following content:
#!/bin/sh git checkout -fand then just make it executable
chmod +x hooks/post-receiveOn the local side just add a new remote and push to it ;)
git remote add web ssh://balrok@balrok.com/home/balrok/balpage.git git push web master
And that yii will work we have to do something more:
after pushing to the remote our workdir will be available and we have to create some files
mkdir www/balpage/assets chmod 777 www/balpage/assets mkdir www/balpage/runtime chmod 777 www/balpage/runtime
Finish Automatic script since i will now publish all my projects in that way an automated script will do it now:
PROJECTNAME="balpage" PUBLISHPLACE="/var/www/yii/balpage" mkdir $PROJECTNAME.git cd $PROJECTNAME.git git init --bare git config core.worktree $PUBLISHPLACE git config core.bare false git config receive.denycurrentbranch ignore cat > hooks/post-receive #!/bin/sh git checkout -f chmod +x hooks/post-receivethen the local place
git remote add web ssh://balrok@balrok.com/home/balrok/balpage.git git push web master
mkdir $PUBLISHPLACE/assets chmod 777 $PUBLISHPLACE/assets mkdir $PUBLISHPLACE/runtime chmod 777 $PUBLISHPLACE/runtime