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\]"