Posts Tagged ‘pragmatic programmers’

Color Coding in Git

December 3, 2009

I recently started reading Pragmatic Version Control Using Git.  Some of the early stuff will be review, but I don’t have a solid foundation in the server-side aspects of Ruby on Rails, so I’m working on it.  In the first chapter, I stumbled on a real gem: Git can be configured to spit out the familiar red-green color coding that we all know and love in autotest and other red-green-refactor testing.  (You are using Test Driven Development, right? )

Enter this at a command prompt:

git config --global color.ui "auto"

That makes your git output (after making changes) look like this:

mysite$ git status
# On branch master
# Changed but not updated:
#   (use "git add ..." to update what will be committed)
#   (use "git checkout -- ..." to discard changes in working directory)
#
#	modified:   index.html
#
no changes added to commit (use "git add" and/or "git commit -a")
mysite$ git add index.html
mysite$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD ..." to unstage)
#
#	modified:   index.html
#

If this doesn’t seem like much, it’ll get much more important when you’re looking at a long list of files in different states.


Follow

Get every new post delivered to your Inbox.