1. Download git-prompt.sh and saved as hidden file .git-prompt.sh curl -L https://raw.github.com/git/git/master/contrib/completion/git-prompt.sh -o ~/.git-prompt.sh 2. apply git-prompt and insert branch variable $(__git_ps1) in prompt in your shell configuration file (ex: ~/.bashrc) # colors MAGENTA="\[\033[0;35m\]" YELLOW="\[\033[0;33m\]" BLUE="\[\033[34m\]" LIGHT_GRAY="\[\033[0;37m\]" CYAN="\[\033[0;36m\]" GREEN="\[\033[0;32m\]" COLOR_OFF="\[\033[0m\]" # set customized prompt source ~/.git-prompt.sh GIT_PS1_SHOWDIRTYSTATE=true export PS1='\u@\h \w'$YELLOW'$(__git_ps1 "(%s)")'$COLOR_OFF' \\$ ' export SUDO_PS1="[\u@\h \w]\\$ " # PS1 only for sudo