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:
Install bash-completion
% sudo port install bash-completion
Add following line into .bash_profile, so that you can use default completions
[ -f /opt/local/etc/bash_completion ] && . /opt/local/etc/bash_completion
After bash-completion is ready, you still need two additional completions before installing gitflow extensions.
Install git-bash-completion
% curl -O https://github.com/git/git/raw/master/contrib/completion/git-completion.bash -o ~/.git-completion.sh
Enable git-bash-completion by adding following into .bash_profile
[ -f ~/.git-bash-completion.sh ] && . ~/.git-bash-completion.sh
Install git-flow-completion
% curl -O https://github.com/bobthecow/git-flow-completion/raw/master/git-flow-completion.bash -o ~/.git-flow-completion.sh
Again, add following into .bash_profile to enable it
[ -f ~/.git-flow-completion.sh ] && . ~/.git-flow-completion.sh
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.
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.
To follow yesterday’s post, here’s how to setup Redmine, another issue tracking system, on local Mac. Comparing with Trac, I can’t say which one is better, but I think I would like to give Redmine a chance (at least for the next few weeks).
You need to make sure you have these ready on you Mac:
Git
You can use MacPorts, i.e.,
% sudo port install git
Ruby Gem: rails and sqlite3-ruby
It can be done by:
% sudo gem install rails
% sudo gem install sqlite3-ruby
% sudo gem update
Basically, it only takes few steps. You first clone redmine from github, create database.yml and edit environment.rb files, then initialize it.
% git clone https://github.com/edavis10/redmine.git
% cd redmine/
% vi config/database.yml
# You can check database.yml.example for more detail
production:
adapter: sqlite3
database: db/redmine.db
% vi config/environment.rb
# Insert this line in Rails::Initializer.run section with your own key and secret (30 chars+)
config.action_controller.session = { :key => "org.redmine.session.key", :secret => "secret.phrase.that.need.to.be.at.least.30.chars.long" }
% rake db:migrate RAILS_ENV=production
% rake redmine:load_default_data RAILS_ENV=production
Then you follow the prompt to setup your environment, and start the Redmine:
% script/server -e production
Use Safari to connect http://localhost:3000, default username and password are “admin”.

To add Git repository in Redmine project, you need to choose SCM (for Git) in Settings’s Repository tab, and provide “Path to .git directory.” e.g. if your git repository is /path/to/my/git/project, you should type /path/to/my/git/project/.git in that field.
I tried to setup a bug and issue tracking system on my Mac last night, and hope to switch away my “primitive Stikit™ notetaking” system. I don’t need power tools, and only have three basic requirements for the tracking system:
There’re several candidates, e.g. Trac, Redmine, and Mantis, etc. But this post will focus only on Trac, with a simple go through about how I install and setup the environment on my Mac.
I use MacPorts to install Trac, which is pretty easy. Just type:
% sudo port install trac
Once it finished, your Trac is basically ready for use, but it only has built-in svn support, so we need to add GitPlugin to enable git support.
We need to use easy_install to install GitPlugin, it’s a module bundled in the python package called setuptools.
Install setuptools is easy too. Since we’re using built-in python 2.6 on Mac, just download python egg shell script setuptools-0.6c11-py2.6.egg from Python Package Index.
Note: if you download it with Safari, the file name will be
setuptools-0.6c11-py2.6.egg.sh, please rename it back tosetuptools-0.6c11-py2.6.egg.
Then we install setuptools-0.6c11-py2.6.egg by typing:
% sudo sh setuptools-0.6c11-py2.6.egg
And install GitPlugin:
% easy_install http://github.com/hvr/trac-git-plugin/tarball/master
Now you have a Git supported Trac on your Mac.
It’s also easy. You decide a directory for Trac to save configurations, I use /Users/[username]/Trac/[projectname], and initialize the Trac by typing:
% trac-admin /Users/[username]/Trac/[projectname] initenv
trac-admin will guide you through two or three steps to create the environment.
I create subfolders in /Users/[username]/Trac/ directory, and use command above to init each of them that maps to my different projects.
Each Trac environment contains a trac.ini file in /Users/[username]/Trac/[projectname]/conf/ directory. Open it with any text editor, and add following:
[trac]
repository_dir = /path/to/your/git/repository/.git
repository_type = git
[components]
tracext.git.* = enabled
[git]
## let Trac cache meta-data via CachedRepository wrapper; default: false
cached_repository = true
## disable automatic garbage collection for in-memory commit-tree cache; default: false
persistent_cache = true
## length revision sha-sums should be tried to be abbreviated to (must be >= 4 and <= 40); default: 7
shortrev_len = 6
## (0.12.0.3+) minimum length for which hex-strings will be interpreted as commit ids in wiki context; default: 40
wiki_shortrev_len = 7
## executable file name (in case of doubt use absolute path!) of git binary; default: 'git'
git_bin = /opt/local/bin/git
## (0.12.0.5+) define charset encoding of paths stored within git repository; default: 'utf-8'
git_fs_encoding = utf-8
## (0.12.0.3+) enable reverse mapping of git email addresses to trac user ids; default: false
trac_user_rlookup = true
## (0.12.0.3+) use git-committer id instead of git-author id as changeset owner; default: true
use_committer_id = false
## (0.12.0.3+) use git-committer timestamp instead of git-author timestamp as changeset time; default: true
use_committer_time = false
If you want to use your own Trac logo, also editing:
[header_logo]
alt = alt for your trac logo
height = 57
link =
src = site/MyTracLogo.png
width = 57
And place image into /Users/[username]/Trac/[projectname]/htdocs/ directory, where map to src’s site/ path.
After you finished setting Trac, you can simply running it by:
% tracd --port 8000 -e /Users/[username]/Trac
And use Safari to connect http://localhost:8000, and click the Trac projects listed in the page.

If you want to launch tracd automatically, just create a plist file for launchd. And save this plist in /Library/LaunchAgents/ if you want tracd to launch after system startup, or /Users/[username]/Library/LaunchAgents/ if you want tracd to launch after [username] login.

You can also launch or stop it by:
% launchctl load /Users/[username]/Library/LaunchAgents/com.digdog.tracd.plist
% launchctl start localhost.trac
% launchctl stop localhost.trac
That’s it. Happy(?) issue tracking.

I tried several scripts that update the CFBundleVersion in Info.plist with Git hash string, but most of them did not work as advertised. This is because the new Xcode will save Info.plist in binary plist format, and the scripts that manipulate them directly as plaintext make it junk.
So I create one for my own. It’s written in ruby, and you don’t need to any other ruby gem when using this script in Xcode.
The script is available on github.
Before today, I was using my lovely, 3 years old, Mac mini as remote Subversion server, and checkout projects to my MacBook through command-line tools or the limited Xcode’s SCM (software control management) Subversion support. And yes, I am not very satisfied with svn, and I bet you know the reason.
And Git is such a wonderful experience, if you tried GitHub. So, I was serious considering to migrate from Subversion to Git in these two days, but it’s really a hard decision, especially when Xcode is not supporting Git right now, which means you will have to make a turn and back to your shell prompt. But anyway, I stepped out into the bright sunlight from the darkness of…, huh, I switched. Cleanly moved from Subversion to a remote Git repository. Here are the steps, hope this helps those who wants to do the same:
Unlike other UNIX platforms, installing Git on Mac OS X is super easy. Assuming you had latest Xcode and MacPorts installed, then simply type the command in Terminal:
$ sudo port install git-core +svn +bash_completion
It takes maybe 10 to 20 minutes, depends on your CPU power, and everything is all set. I installed it on both my Mac mini (server) and Macbook (client).
Connect to the server, and setup a new “bare” Git repository:
$ ssh mini.local
Password:
Last login: Sat Mar 14 20:44:00 2009 from macbook.local
$ cd ~/
$ mkdir ~/git/
$ mkdir ~/git/projectname.git
$ cd ~/git/projectname.git
$ git --bare init
Initialized empty Git repository in /Users/digdog/git/projectname.git
$ exit
That’s it for the server side. You just create an empty remote repository for storing deltas and binaries later from your working Git repository.
Back to client side, first create a Git repository, and use git-svn to fetch code from your Subversion repository on the server, then clone it to a normal Git repository that does not have stuffs for supporting git-svn, and finally, push back to remote git repository.
Here’s how I did:
$ cd ~/
$ echo "digdog = digdog <digdog@my.email.address> > user.txt
Create a text file that contains username to allow us mapping from Subversion user to Git user later.
$ cd ~/
$ mkdir svn_to_git
$ cd svn_to_git
$ git svn init svn+ssh://mini.local/Users/digdog/svn/trunk/projectname --no-metadata
$ git config svn.authorsfile ~/user.txt
$ git svn fetch
Create a temporary directory called “svn_to_git”, then initialize this directory as Git repository, and point it to the SVN repository on my Mac mini server. Next, ask Git to use user.txt to map Subversion user to Git user in next command. Following the step sixth, fetch all the source code from server.
$ cd ~/
$ git clone svn_to_git temp_projectname
$ cd temp_projectname
$ git remote rm origin
$ git remote add origin ssh://mini.local/Users/digdog/git/projectname.git
$ git push origin master
In step two, clone the svn_to_git repository to a another temporary repository, which will will push back to remote repository later. And delete remote branch after cloning in step fourth. Step Five, add the remote repository to local temporary repository configuration, as a remote server called “origin”. At the end, we push local master branch (in temporary repository) to the origin’s master branch (on the server).
So we finished, just clone it:
$ git clone ssh://mini.local/Users/digdog/git/projectname.git
and push/pull your code like a happy Git user.
loading…