IdolHands.com :: Days in the Life of an Alpha Geek
Update: The Git script described below has been updated, improved, and folded into the BBRails Toolkit.
In the two short years since its 1.0 release, the open-source version control system Git has grown to become the SCM of choice for open source and web development projects worldwide. Last year we took the plunge and moved all of our projects to Git from SVN. I won't say that it hasn't been a rocky transition, but I'm hopeful that in the long run it will prove to have been the right decision.
One of the niceties of SVN was the fact that BBEdit supported it out of the box. No such support exists for Git, unfortunately, so I found myself having to make frequent trips to the command line (or the only decent Git client I can find, GitX) for anything Git-related.
One could argue that due to its complexity— think branching, one of the strong points of Git— full-fledged Git integration would be beyond the scope of an IDE. But there are definitely basic things that would be nice to do without command-tabbing out of BBEdit.
To that end, I've created a basic AppleScript that lets you perform the two most common (for me, anyway) Git operations from within BBEdit: git status and git pull.

If there are no conflicts with your pull operation, the script lets you know with a dialog box.
Otherwise, the results are opened in a new BBEdit window.

Similarly, 'status' will give you a quickly dismissable dialog box if you're up to date,
or full list of changes in a new window.
To install:
~/Library/Application Support/BBEdit/Scripts/Make sure that the accompanying shell script has execute privileges:
chmod +x ~/Library/Application Support/BBEdit/Scripts/Git/find_enclosing_project.shIn BBEdit, assign a keyboard shortcut to the script:
Now, with any file open in your Project window, you can activate the Git script using the keyboard shortcut you assigned. The script determines the location of your local Git repository and performs the command you select (status or pull).
Robert Hanviriyapunt's UNIX wizardry was critical for creating the shell script to determine the current Git repository for the selected file— many thanks, Robert!
If you have any suggestions on how to improve the script, please let me know by leaving a comment below. Happy hacking...
![]()
Brad Gessler
February 1, 2009 at 8:04 AMI've got to share gitx in any git post: http://gitx.frim.nl/ Its a a gitk that doesn't suck!
![]()
Peter Murphy
February 24, 2009 at 4:17 PMBugger off you git.
![]()
Corey Ehmke
February 24, 2009 at 4:35 PMPeter-- er, Jon-- you've got a memory like an elephant! Thanks for the chuckle.