Tuesday 26 February 2013

git hooks rock on Windows 8!

I love git, I absolutely love it!

I particularly love it because it allowed me to deploy to the now defunct PHPFog... I developed an application for a friend on PHPFog but when they said they were closing down and suggested that existing users move to AppFog I was less than pleased! That was until I spent a rainy Saturday afternoon getting my head around the af command and I started to like it.

That was until Windows 8 died on me and I had to do a fresh install. I managed to get git up and running again eventually, probably thanks to the encouragement of Ravishankar Somasundaram and his cracking Git: Version Control for Everyone. Then I started looking around to see if I could still use git in a meaningful way and found this lovely link about git hooks.

Now I develop on Windows 8 and it's not as simple as all that to get your head around but the way I did it was to go to the git hooks github site and copy the resulting script into Sublime Text 2 (Go on, buy it!). Save it as git-hooks (sans file extention) into C:\Program Files (x86)\Git\cmd, or wherever git resides. Then, within your project directory run git hooks --install. This creates an empty hooks folder within your .git directory. Now the fun begins...

Basically you'll need to create a .bat file to run. I needed it to run after git commit so I deleted all the files except for post-commit and replaced all the text in there:

af login --email <email address> --passwd <password>
af update <project_name>
echo Updated

Now I can keep my version control in place and I don't need to worry about deploying the project as git does it for me ;-).

No comments:

Post a Comment