Git Color Highlighting in Terminal

Published on Jan 2, 2015
Working with Git in the terminal can be hard to read and navigate at times. For the last year I have been forcing myself each day to use the terminal much more to get used to doing things without an interface. One pet peeve that I had was that my terminal text was always white on black and extremely hard to read. Then I stumbled across [Cheat Sheets](http://cheat.errtheblog.com/s/git) and figured out a way to get the terminal to work a little better for me. ![Git Color Highlighting](/blog/git-color-highlighting-in-terminal_1.jpg) ## Option - Edit the File First, all the modifications that we're making are to the ~/.gitconifg file located in your root user directory on Mac. In this file we will be adding the following lines of code. [color] ui = auto [color "status"] added = green changed = yellow untracked = cyan If you feel safer opening this file in your code editor of choice and adding the lines you can feel free to do that. Personally, I preferred to let the terminal do this work for me and thus turned to running a few terminal commands to add the lines of code that I needed. ## Option - Using the Terminal To turn on the default terminal coloring: $ git config --global color.ui true Git will now color the output it sends to the terminal. In my case all my terminal commands are "red" for modified and deleted files or "green" if they were added ready for commit. ![Git Color Highlighting](/blog/git-color-highlighting-in-terminal_2.jpg) You could stop here and probably be completely happy with everything, however, I wanted to take this a little step further and allow for a little more color variation in order to see what changes were being made in the terminal. In the code snippet above I have added a `color="status"` section which fine tunes the color variations between the different statuses a file could be in during a Git commit. For example, untracked files I wanted to be "cyan" while my changed files were "yellow" rather than red (More of a personal preference rather than a general need). Running the following three commands in the terminal will add the color options that I specified below. $ git config --global color.status.added green $ git config --global color.status.changed yellow $ git config --global color.status.untracked cyan Now when you run `git status` you will see the following: ![Git Color Highlighting](/blog/git-color-highlighting-in-terminal_3.jpg) Hope that this helps with your journey with the terminal or an CLI type interface. ## Resources If you're unfamiliar with Git or the Terminal please feel free to read these articles that show you the basics and what you can use them for. - [Getting Git Right](https://www.atlassian.com/git/) - [Try Git](https://try.github.io/levels/1/challenges/1) - [How Can I Quickly Learn Terminal Commands](http://lifehacker.com/how-can-i-quickly-learn-terminal-commands-1494082178) - [The Command Line Crash Course](http://cli.learncodethehardway.org/book/)
Justin Hough author picture
Justin Hough

Chief Development Officer at Hounder. He is a Christian, husband, father, writer, developer, designer, and a digital carpenter crafting amazing web experience. Also, created the Centurion Framework many moons ago.