Notes on Life, ‘Puters and Hawaii

Installing GIT on Mac OS X 10.5 Leopard

Update: Tim Harper points out in the comments there is now a fairly up to date OS X installer at google code if you would rather not deal with building it yourself. Easy! (You’ll still want to do the configuration part at the end of this article, though, using the scripts starting at “alias g”)

Here’s how I compiled Git source control on OS X Leopard.

# GPG (if you didn't have it already)
curl ftp://ftp.gnupg.org/gcrypt/gnupg/gnupg-1.4.7.tar.bz2 | tar xj
cd gnupg-1.4.7
./configure
make
sudo make install
cd ..

# GetText
curl http://mirrors.usc.edu/pub/gnu/gettext/gettext-0.17.tar.gz | tar xz
cd gettext-0.17
./configure
make
sudo make install
cd ..

# GIT
curl http://kernel.org/pub/software/scm/git/git-1.5.5.tar.bz2 | tar xj
cd git-1.5.5
./configure
make
sudo make install
cd ..
curl  http://www.kernel.org/pub/software/scm/git/git-manpages-1.5.5.tar.bz2 | \
sudo tar xj -C /usr/local/share/man

# alias "g" for "git"
cat >> ~/.profile << \EOF
alias g='git'
export PS1='$(git branch &>/dev/null; if [ $? -eq 0 ]; then \
echo “\[\033[00m\]$(git branch | grep ^*|sed s/\*\ //) “; fi)\$\[\033[00m\] ‘
EOF
source ~/.profile

# you
git config –global user.name “Mr Man”
git config –global user.email “mr@man.com”

# colors
git config --global color.diff auto
git config --global color.status auto
git config --global color.branch auto
git config --global color.interactive auto

# shortcuts
git config –global alias.st status
git config –global alias.ci commit
git config –global alias.co checkout
git config –global alias.br branch

# if you ever have conflicts you can type git-mergetool
# to use Apple opendiff (FileMerge) for resolving conflicts
git config –global merge.tool opendiff
# Whenever we merge provide a summary of commits
git config –global merge.summary true

# globally ignore some cruft files
git config –global core.excludesfile ~/.gitignore
echo “*~” >~/.gitignore
echo “.DS_Store” >>~/.gitignore

# setup nice fonts on gitk
cat >~/.gitk <<\EOF
set mainfont {Monaco 10}
set textfont {Monaco 10}
set uifont {Monaco 10}
EOF

Also check http://git.or.cz/gitwiki/GitTips for more tips.

26 Responses to “Installing GIT on Mac OS X 10.5 Leopard”

  1. Thanks! This was really helpful.

    One comment: your blog formatting is screwing up a few of these commands. For example, the last three commands (git config …), your blog software is taking the ‘dash dash global’ part of the command and making the two dashes into an em dash (the typographic dash). So when people copy and paste, these commands don’t work. I assume that this is due to textualize or markdown.

    Thanks again.

  2. Sorry about the formatting goof. I have corrected it and also updated the instructions for git 1.5.4

  3. Helpful for me too - worked a treat. Thanks…

  4. Tim - Worked great! Thanks!

  5. Aloha! I have been able to follow along successfully until I try to make git. It fails because it can’t find msgfmt (from gettext, right?). Any clues as to what I should try? Here is the error after running make git…

    msgfmt –statistics –tcl po/de.po -l de -d po/
    make[1]: msgfmt: Command not found
    make[1]: *** [po/de.msg] Error 127
    make: *** [all] Error 2

  6. Nice and simple instructions, thanks Tim!

  7. For users of MacPorts (formerly known as DarwinPort), you can install simply by running

    port install git-core

    and if you like cogito:

    port install cogito

    Easy as pie!

    - Simon

  8. using MacPort you are messing up your system with software which is already installed outside the ports folder. For example perl and many libs

  9. You can see from my other posts that I don’t like fink or macports. They end up installing old versions of the software you want. For example, with git you would not get the latest stable version going with macports. Plus macports will re-install perl and other stuff that’s already on your mac.

  10. It worked flawlessly! Thanks!

  11. Great thanks, worked like a charm!

  12. [...] Installing Git on OSX [...]

  13. Just a quick note to say “thanks” to dysinger for this. I actually found this page looking for any gotchas using macports to install git, but this looks like it will do the job too.

    Just one thing before I go - fair play if you dislike macports, but bear in mind that while it “reinstalls” various bits and bobs to ensure that all your software has its preferred version of (say) Perl available to it, it doesn’t “mess with your system software”. Rather it installs its OWN versions of these into /opt, which the system doesn’t touch. The disadvantage here is that, yes, you may get older versions of your software. The advantage (and huge win IMHO) is that when Apple issues a system update and updates the system version of Perl (say), you risk the other stuff you’ve installed breaking.

    Anyway, thanks for the walkthrough.

  14. Of course, the last part of my comment should have said “you *mitigate* the risk of your other installed stuff breaking, as the version of Perl it depends on is in /opt.”

  15. [...] There is a newer article on this at this [...]

  16. [...] Tim Dysinger » Installing GIT on Mac OS X 10.5 Leopard (tags: git leopard) [...]

  17. macports rocks. use it.

  18. Kyle: I was receiving that same error. I found the following solution (via Shawn O. Pearce at http://article.gmane.org/gmane.comp.version-control.git/72903).

    Use:

    make NO_MSGFMT=1

    to use the msgfmt work-somewhat-alike that ships with git, for this exact purpose.

  19. Very useful, thanks!

  20. Here’s a link to the Git OS X install packages:

    http://code.google.com/p/git-osx-installer/

    (btw, I like your name, Tim!)

  21. Cool Tim! Thanks for the link!

  22. [...] Tim Dysinger » Installing GIT on Mac OS X 10.5 Leopard (tags: git alias list short) [...]

  23. tx to jeremy (make NO_MSGFMT=1)
    works on darwin 8.8.0 / 10.4.8 powerbook g4/887, but build took a while :)

  24. Textmate junkies: git config –global core.editor “mate -w”

  25. [...] Installing GIT on Leopard [...]

  26. [...] o download do pacote e apertar ‘next’, ‘next’, ‘finish’. Para instalação via shell é necessário compilar o GIT e outras coisinhas [...]