Check out example codes for "git branch in my bash prompt". It will help you in understanding the concepts better.

Code Example 1

parse_git_branch() {
     git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\[email protected]\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "

Learn ReactJs, React Native from akashmittal.com