Categories
post

Pre-Commit Fails When Removing a File From Git

I just blogged about automatically running PHP Lint when committing a file into the repo. Well I also had the joy of it failing because I removed a file.

If you get “Could not open input file: abc.php”, then you may have the same problem I did.

There’s an easy solution. The pre-commit file looks for all changed files. Technically, a removed file is changed, but it also doesn’t exist when you go to run php -l against it.

Open your pre-commit file, and change the line that looks like this:

exec(“git diff-index –cached –name-only {$against}”, $output);

to

exec(“git diff-index –diff-filter=ACMRTUXB –cached –name-only {$against}”, $output);

Categories
post

Run PHP Lint before committing to GIT

This is going to sound stupid, but if you don’t have rock solid unit tests in place, one of the things you should be doing is running PHP Lint.

What is PHP Lint?
Simply stated, it checks your php file for syntax errors. How many times have you forgotten a semi-colon, or had unmatched curly braces?

How do I run PHP Lint?
It is very easy to run from the command line
php -l your_php_file.php

Using GIT? You should setup a pre-commit hook to always do this so you don’t push something bad into the repo. I am guilty of doing this in the past. 🙁

Here is a great post by Travis Swicegood about setting this up.
http://phpadvent.org/2008/dont-commit-that-error-by-travis-swicegood

One thing to remember is that you also have to make the script executable.
chmod 744 .git/hooks/pre-commit

Categories
post

Why Aren’t You Using Git Flow?

I gave a presentation at Orlando PHP last night. I had a great time, and everyone there was fantastic.

I really want to improve my public speaking. I gave a very simple introduction of myself to a Google Checkout panel a few years ago and thought I was going to passout. I felt I did a horrendous job, and all I was doing was talking about myself and the company I work for.

Enough about that. Last night I was running late due to traffic on I-4 because of the rain. I got there and was very surprised to see one of the biggest turnouts we have ever had for Orlando PHP. I quickly setup my computer while David Rogers talked a little about GIT.

I sped through my slides a little bit. I really didn’t want to just sit there and read what was on them. I wanted to be personable, clear spoken, and desperately wanted to avoid filler noises (ah’s, umm’s, like’s and you know’s). Overall I am very happy with the way it turned out.

Had I gotten there early, I would have setup a tripod and camera to tape it. Because I was running late, I scrapped that.

People were asking me some great questions, and I hope I took enough time to answer to the best of my ability. Some things I deferred to other members of the group that had better answers. Thank you Ketema for stepping in where you could.

I have become very passionate about using Git & Git Flow for my development. It has truly made me a better developer, rather than just a hacker.

Thank you to Vincent Driessen for sharing his git workflow originally. I used it for a couple of weeks, but ultimately did not keep up with it. At some point he released the “git flow” tools that I used in my presentation. I became aware of these tools thanks to Jeff Kreeftmeijer who wrote a blog post titles “Why Aren’t You Using Git Flow?

I have some resources at the end of the slides that you can refer to.

Categories
post

Git and Git Flow Usage

I saw this image about a successful git branching model. http://nvie.com/posts/a-successful-git-branching-model/

It made perfect sense while looking at the graphic, however implementation proved to be more difficult for me. I am a one man shop, so it is too easy to get confused when I don’t have to worry about other developers.

I then saw a tweet about Git Flow. I didn’t put two and two together that it involved this very image. If you are considering Git and looking for a good routine, definitely look into this.

https://github.com/nvie/gitflow
Why aren’t you using git flow?

Also look at the bash completions, I highly recommend them.
http://github.com/bobthecow/git-flow-completion

Categories
status

Git is back in my life to stay this time…

Git is back in my life to stay this time. I have started and stopped using GIT on the same project numerous times. Each time I felt I was using it incorrectly or effectively and in the end I would just stop.

I have picked it back up, and this time started using a script that would take my ‘git log’ entries and put them into MySQL. I then created a report for my boss to be able to see every change I make.

I am the only “tech” here, so nobody has held me accountable in the past. I need to do it myself.