Beyond The Type

Guide to installing git on a (Intel based) Mac

June 15th 2007

git logo Ever used SVN or SVK? Git is another source code management (scm) system that has been getting a fair bit of attention of late. I recommend giving it a try if you haven’t done so already.

Unfortunately it can live up to it’s name when it comes to installing on an Intel based Mac. More so if you recently migrated from a PPC Powerbook and hadn’t updated your Darwin ports. All your libraries are likely to be compiled for the wrong architecture leaving you with messages like this:

/usr/bin/ld: warning /opt/local/lib/libz.dylib cputype (18, architecture ppc) does not match cputype (7) for specified -arch flag: i386 (file not loaded)

The long and the short of it is that you will need to re-install darwin ports from scratch and then do a manual install.

Here are the steps you take:

  1. Make sure you have the latest version of XCode: http://developer.apple.com/tools/download/

  2. Remove ports (this will be the case if you have installed ImageMagick or similar in the past) See http://www.nabble.com/I’ve-hosed-my-ports-install,-clean-slate-install—t3868686.html

    Always backup before you do these kind of things, esp if you depend on anything in your ports install

  3. Reinstall Darwin ports: http://darwinports.com/download/

  4. Install git through ports (this only gets you the 1.4.2 version though)

    sudo port install git-core
    

    At this point you could just stop but if you want the latest and more advanced features its worth
    carrying out a manual install. Especially if you want to transfer files from an existing SVN repo.

  5. Install git manually (now you have dependencies from the dawinports install)

    cd /usr/local/src
    curl http://kernel.org/pub/software/scm/git/git-1.5.2.1.tar.gz > git-1.5.2.1.tar.gz
    tar -xvzf git-1.5.2.1.tar.gz
    cd git-1.5.2.1
    make configure
    ./configure --prefix=/usr 
    sudo make install
    
  6. Test it out

    martin$ git --version
    git version 1.5.2.1
    martin$ git-svn --version
    git-svn version 1.5.2 (svn 1.4.3)
    martin$ git
    usage: git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate] [--bare] [--git-dir=GIT_DIR] [--help] COMMAND [ARGS]
    
    The most commonly used git commands are:
    add           Add file contents to the changeset to be committed next
    apply         Apply a patch on a git index file and a working tree
    archive       Creates an archive of files from a named tree
    bisect        Find the change that introduced a bug by binary search
    branch        List, create, or delete branches
    checkout      Checkout and switch to a branch
    cherry-pick   Apply the change introduced by an existing commit
    clone         Clones a repository into a new directory
    commit        Record changes to the repository
    diff          Show changes between commits, commit and working tree, etc
    fetch         Download objects and refs from another repository
    grep          Print lines matching a pattern
    init          Create an empty git repository or reinitialize an existing one
    log           Show commit logs
    merge         Join two or more development histories together
    mv            Move or rename a file, a directory, or a symlink
    prune         Prunes all unreachable objects from the object database
    pull          Fetch from and merge with another repository or a local branch
    push          Update remote refs along with associated objects
    rebase        Forward-port local commits to the updated upstream head
    reset         Reset current HEAD to the specified state
    revert        Revert an existing commit
    rm            Remove files from the working tree and from the index
    show          Show various types of objects
    show-branch   Show branches and their commits
    status        Show the working tree status
    tag           Create, list, delete or verify a tag object signed with GPG
    (use 'git help -a' to get a list of all installed git commands)
    
  7. Done!

In summary

This is all bit a convoluted to be honest so if you have a better way then please feel free to chip in. Hopefully though if you end up in the same situation this might be the helping hand you were looking for.

Further notes

Note: to get the docs to install you need to also install

sudo port install xmlto
sudo port install asciidoc

However I kept encountering time outs trying to pull libxslt (a dependency) from an external source so I moved on and skipped the docs for now.

If you want to use the git-svn command and end up with messages like this: “Can’t locate SVN/Core.pm in'. It might because you installed SVN from an installer. In which set the perl lib path to the parent directory of where SVN/Core.pm is located. In my case:

export PERL5LIB=“/usr/local/svn/perl/darwin-thread-multi-2level”

References:

Thanks to:

Recommend Me

blog comments powered by Disqus