Deploy website with Git bare

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

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
git checkout -f
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
git checkout -f [BRANCH_NAME]

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.

Leave a Reply

Your email address will not be published.