Setup git-flow on Mac OS X Lion

git-flow is a branching model to keep your git repository in shape, and the author @nvie also released it as git extensions, so that you can easily convert your git repository into git-flow branch structure and keep maintained (with ease).

Below are the steps I setup git-flow on my Mac OS X Lion:

MacPorts and bash-completion

  1. Install Xcode
  2. Install MacPorts
  3. Install bash-completion

    % sudo port install bash-completion

  4. Add following line into .bash_profile, so that you can use default completions

    [ -f /opt/local/etc/bash_completion ] && . /opt/local/etc/bash_completion

git-bash-completion and git-flow-completion

After bash-completion is ready, you still need two additional completions before installing gitflow extensions.

  1. Install git-bash-completion

    % curl -O https://github.com/git/git/raw/master/contrib/completion/git-completion.bash -o ~/.git-completion.sh

  2. Enable git-bash-completion by adding following into .bash_profile

    [ -f ~/.git-bash-completion.sh ] && . ~/.git-bash-completion.sh

  3. Install git-flow-completion

    % curl -O https://github.com/bobthecow/git-flow-completion/raw/master/git-flow-completion.bash -o ~/.git-flow-completion.sh

  4. Again, add following into .bash_profile to enable it

    [ -f ~/.git-flow-completion.sh ] && . ~/.git-flow-completion.sh

git-flow extensions

Once you completed steps above, the git and git-flow completions are integrated into bash, so we can proceed to the final step, install the git-flow git extensions:

% git clone --recursive git://github.com/nvie/gitflow.git
% sudo make prefix=/opt/local install

That’s it.

For usage, read this article.

Update

If you don’t mind installing dependent packages, you can use:

% sudo port install git-flow

Which saves lots of times, if it doesn’t break build.

References