Installing Git on my Mac
Inspired by Dr Nic’s post I wanted to install git on my Intel-based Mac. Why? There were two motivations – I frequently do work on the train or tram, and less often on planes, which is the reason Nic describes, but I also wanted to be able to commit mini-milestones on my local machine that I’m not really ready to commit to the “point of truth” on svn. This is the point where I reveal that I don’t do all of my programming test first, but that’s a longer thread. Suffice it to say that there are periods where I need to work to get the test coverage back over the threshold (currently set to 99.2%) and I don’t want to commit to svn until the test coverage is back there.
I installed git-core from MacPorts, but when I ran git-svn I didn’t have a “clone” command, which is what all the cool kids are talking about. I’m still not sure that I know precisely why that was the case, but in poking around on the web I found a few places with installation instructions, and eventually things were working, so I’ll add what I did to the pool (my main motivation is letting you know the problem I was trying to fix though).
- Followed the instructions from http://www.beyondthetype.com/2007/6/15/guide-to-installing-git-on-a-intel-based-mac to install the latest version of Git from source
- Re-installed subversion using the package from http://downloads.open.collab.net/binaries.html. Why? Because the last step in the previous instructions (setting the PERL5LIB) didn’t help, and I couldn’t find the svn-perl libraries anywhere. The instructions on http://speirs.org/2007/07/22/getting-git-svn-working-on-the-mac/ were helpful. After the subversion installation I had a directory /usr/local/lib/svn-perl, which did the job.
- Added export PERL5LIB=’/usr/local/lib/svn-perl’ to my .profile
- Added /usr/local/git-1.5.2.1 to PATH in my ,profile (early on, to make sure git was found here first)
- When I tried git-svn I got an error concerning Term::ReadKey when perl tried to prompt me for a password. I tried to install Term::ReadKey from CPAN interactively (sudo perl -MCPAN -e ’shell’
, then ‘install Term::ReadKey’, but got “Can’t exec “./make”: No such file or directory at /System/Library/Perl/5.8.6/CPAN.pm line 4566.”. The answer was to change directory to ~/.cpan/build/TermReadKey-2.30 and execute the following commands: sudo perl MakeFile.pl; sudo make; sudo make test; sudo make install. Now I have the Term::ReadKey module installed! - When I tried to ‘gitify’ after that, I got this message : “error: More than one value for the key svn-remote.svn.fetch: :refs/remotes/git-svn”. This seems to have been caused by previous failed attempts – removing the xxx.git file and running ‘gitify’ again seemed to work.
For people like me who are less than clear about the result, here’s what you get:
- A copy of your project in ‘../project_name.git’. This is your git working directory.
- Your repository is in .git in the git working directory.
- Change into the git working directory and start doing your stuff
- You’ll probably find these commands useful:
- git status : tells you what’s uncommitted
- git add : adds a new file to version control. “git add *” seems to do everything you’d want
- git checkout -f : reverts local changes
- git commit -a : commits any modifications (but not new files) to the repository
- git-svn rebase : merge svn changes into your git repository
- git-svn dcommit : commits all your changes back to svn
And if I’d known it was going to be this hard when I started, I wouldn’t have.






I agree – its non-trivial, and not quick to install. Plus there’s no easy installer for Windows. Definitely two negatives.
You should have used the svn variant:
port install git-core +svn
otherwise it will be build without git-svn support.
I noticed that in someone else’s blog, but only *after* I’d done it without the “+svn”. Unfortunately, I’m rather ignorant of port and I couldn’t see a way to repeat the install with the “+svn”. I tried the obvious – executing the install again – but that didn’t seem to help. Can anyone suggest what I could/should have done at that point?
Someone yesterday suggested it would have all worked well is I’d done an uninstall and then tried the install again with the correct flags. I should have thought of that at the time.
I just installed Git on Mac OSX from download on git-scm.org, and everything needed came with it. So, today it is a lot easier!