It’s difficult to know the name of the current active GIT branch in the terminal so let’s see how to do configuration to show active Git Branch name in Terminal.
- Run below command in terminal to open the file.
sudo vim ~/.bash_profile - Add below code and save the file.
# Display current Git branch in terminal prompt.
parse_git_branch() {
git branch 2> /dev/null | sed -e ‘/^[^*]/d’ -e ‘s/* (.*)/ (1)/’
}
export PS1=”u@h W[33[32m]$(parse_git_branch)[33[00m] $ “
Now access the folder where git repository is present to see that the current active git branch will display in terminal prompt.