Posted by & filed under GIT.

Colored Output:

(notice the red modified and untracked files)

Put the following code in your ~/.gitconfig (global git configuration) file.

        diff = auto
        status = auto
        branch = auto
        pretty = "Commit:  %C(yellow)%H%nAuthor:  %C(green)%aN <%aE>%nDate:    (%C(red)%ar%Creset) %ai%nSubject: %s%n%n%b"

This will give you colored output like the following (notice the red modified file, red untracked file [added files will be green], and the current branch being green [non-current branches will be white]):

Shortcut Terminal Commands:

(notice how the gs command is the same as git status)

Put the following lines into your ~/.bash_profile file, then you can use the two or three character shortcuts to make your life a lot easier.

alias ga='git add'
alias gp='git push'
alias gl='git log'
alias gs='git status'
alias gd='git diff'
alias gm='git commit -m'
alias gma='git commit -am'
alias gb='git branch'
alias gc='git checkout'
alias gra='git remote add'
alias grr='git remote rm'
alias gpu='git pull'
alias gcl='git clone'

Terminal Autocompletion:

(screenshot of tab completion showing a list of all branches)

Download this script, and put it in the root of your home directory:


Now that the script is there, you will need to execute it each time your bash session starts. Put the following code in your ~/.bash_profile file:

if [ -f ~/.git-completion.bash ]; then
    . ~/.git-completion.bash

Also, if you are using the short codes above, you will need to add the following two lines to your ~/.bash_profile as well so that the shortcut commands also get auto completed:

complete -o default -o nospace -F _git_branch gb
complete -o default -o nospace -F _git_checkout gc

Bash Prompt Branch Name:

(notice the master and test in parenthesis)

The following code requires the git-completion.bash script be setup properly (as defined in the above section). Once you have it setup, you can add the following code to your ~/.bash_profile file. It will change your bash prompt to this new. If you are inside of a git repository, it will display the name of the branch. If you aren’t in a git repository, it will just display the path. You may want to tweak it to be a little more familiar; it is based on a standard old linux prompt, and may look out of place depending on your distro or if you are using OS X.

green=$(tput setaf 2)
blue=$(tput setaf 4)
bold=$(tput bold)
red=$(tput setaf 1)
reset=$(tput sgr0)
PS1='\u@\[$green\]\h\[$reset\]:\w\[$blue\]$(__git_ps1)\[$reset\] \$ '

Thomas Hunter II

Thomas is the author of Advanced Microservices and a prolific public speaker with a passion for reducing complex problems into simple language and diagrams. His career includes working at Fortune 50's in the Midwest, co-founding a successful startup, and everything in between.


  • Peter Abrahamsen

    Thanks for this. Have you found a way to color the prompts for the interactive commands, like git commit/add -p? It’s very difficult to figure out how far the chunk under question extends up the screen.


  • Hi,

    Thank you so much for sharing.

    I used part of your solution in conjunction with this piece of code added to .bash_profile

    # Set git autocompletion and PS1 integration

    if [ -f /usr/local/git/contrib/completion/git-completion.bash ]; then
    . /usr/local/git/contrib/completion/git-completion.bash

    if [ -f /opt/local/etc/bash_completion ]; then
    . /opt/local/etc/bash_completion

    On OS X, when you install GIT, the git-complete.bash file gets saved here:


    Kudos to this site for providing an alternate solution:


  • It seems that color.ui=true does all of the above color.diff/status/branch.

    The three lines can be replaced by:

    ui = true

  • I ran into a bunch of errors with this.

    Stripping it all back to my orig now yields this below every time I open up terminal

    -bash: uname: command not found
    -bash: ps: command not found