I tried to follow a few tutorials / howtos but non of them worked perfectly so I decided to write my own how-to. If nothing else I will know which one to follow the next time I came across this problem 🙂
One of the problems (as always) was that some of them were obsolete or did not tell for which git version that how-to is written for…
I was doing this with git version 1.8.3.2
This were my steps:
Server side:
git init --bare git config core.bare false git config core.worktree /home/gasper/website git config receive.denycurrentbranch ignore cat > hooks/post-receive #!/bin/sh git checkout -f ^D chmod +x hooks/post-receive
NOTE: if you want to deploy a specific branch and not ‘master’ branch then you must change hooks/post-receive to:
cat > hooks/post-receive #!/bin/sh git checkout -f [BRANCH_NAME] ^D
Local machine:
git remote add web ssh://myserver/home/gasper/git/somesite.git git push web +master:refs/heads/master
Here are some references:
If you have any questions leave a comment.