Why is the name of the branch I'm currently working not showing up in the terminal

Answered

I just downloaded software and it seems that I have configured the IDE correctly to my GitHub account but other than running the git branch command I am unable to tell which branch I'm on. Is this something that I need to configure?

4 comments
Comment actions Permalink

Hi,

you could find name of the current branch in the right bottom corner of the screen. Would it help you?



Attachment(s):
GitBranch.png
1
Comment actions Permalink

The branch name doesn't appear in my bottom-right-corner. Any idea why not? 

Thanks!

0
Comment actions Permalink

Have you configured VCS in IDEA? If not you could follow tutorial here: https://www.jetbrains.com/help/idea/2016.3/setting-up-a-local-git-repository.html

0
Comment actions Permalink

Hi in order to see branch name in your terminal you need to edit the bash profile.

Please follow below steps for the same:

1. write the command : vim ~/.bash_profile in your terminal

2. In insert mode write(copy) the below script:

c_red=`tput setaf 1`
c_green=`tput setaf 2`
c_sgr0=`tput sgr0`branch_color ()
{
if git rev-parse --git-dir >/dev/null 2>&1
then
color=""
if git diff --quiet 2>/dev/null >&2
then
color=${c_green}
else
color=${c_red}
fi
else
return 0
fi
echo -n $color
}parse_git_branch ()
{
if git rev-parse --git-dir >/dev/null 2>&1
then
gitver="("$(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p')")"
else
return 0
fi
echo -e $gitver
}export PS1='\[\033[31m\]\u \[\033[34m\]\w \[${c_sgr0}\]\[\[$(branch_color)\]$(parse_git_branch)\[${c_sgr0}\]$ '

3. Exit the insert mode by pressing escape key and write :wq + enter key.
4. Restart your terminal.

You'll now be able to see your branch name in terminal.

0

Please sign in to leave a comment.