Ivor O’Connor

September 16, 2009

Git’s Post Receive Hook

Filed under: Uncategorized — ioconnor @ 7:56 pm

I’ve been using git for everything in the World lately. To be honest I’ve not been understanding much of anything I read. I basically read something and then hack around until I get it working. The hack around part is a pain. It consists of writing little scripts and then testing how I think it works and finding it doesn’t really work that way. So then I run the setup script again which erases all the work and initializes everything all over to the point where I failed. So I can try over. And over. And over about 20x.

Anyways, today I read this excellent post http://debuggable.com/posts/git-tip-auto-update-working-tree-via-post-receive-hook:49551efe-6414-4e86-aec6-544f4834cda3 and implemented it. It allows me to simply push the changes out to the webserver without ftp or rsync. It’s quite nice. Just make an executable file at .git/hooks/post-receive and stick in it:

cd ..
env -i /usr/local/bin/git reset –hard

I need to make the .git directory off limits to prying eyes. I will do that in the future. For now though it doesn’t have anything in it that is not already viewable so it’s not important. Later though.


Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: