Super simple git deployments

First time using git to push to a web server. Thanks to this, it works.

Mostly as a record for myself, here’s how I set it up.

Starting on the web server:

mkdir foo
cd foo
chmod g+s .
git init
git config receive.denyCurrentBranch ignore

Then add the following to .git/hooks/post-receive

cd ..
env -i git reset --hard

Now chmod +x .git/hooks/post-receive.

Finally, on my local machine:

git remote add web user@host:/path/to/foo/.git/
git push web master

This works on Ubuntu because the default umask is 0002. Umasks are set per user / process, not on the filesystem, so if you have a umask problem, you’ll have to solve it!

One thought on “Super simple git deployments”

  1. note for myself, if port is not 22, ssh:// and this syntax is the way to go:

    git remote add web ssh://user@host:2222/home/directory/.git

Leave a Reply

Your email address will not be published. Required fields are marked *