As IntelliJ cannot show be my branch I found a way to add the branch to my bash prompt in the terminal. I've added this to my .bashrc file and I get a nice real-time branch indicator.
#Git branch prompt
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
function proml {
local BLUE="\[\033[0;34m\]"
local RED="\[\033[0;31m\]"
local LIGHT_RED="\[\033[1;31m\]"
local GREEN="\[\033[0;32m\]"
local LIGHT_GREEN="\[\033[1;32m\]"
local WHITE="\[\033[1;37m\]"
local LIGHT_GRAY="\[\033[0;37m\]"
case $TERM in
xterm*)
TITLEBAR='\[\033]0;\u@\h:\w\007\]'
;;
*)
TITLEBAR=""
;;
esac
PS1="${TITLEBAR}$RED\u@\h:\w$GREEN\$(parse_git_branch)$LIGHT_GRAY\$ "
PS2='> '
PS4='+ '
}
proml
As of IntelliJ 11 the current Git branch is displayed in the bottom right corner of the status bar. Moreover, clicking on the branch name displays a nice popup with all available branches, and you can invoke some actions on them.
To enable status bar follow the below steps :
View --> Appearance --> Status Bar [and click to enable/disable]
I had an issue whereby I had no git bar or indexing status after moving to IntelliJ 2017.2 - my issue was down to the 'Code Outline' plugin. I deleted it's jar file from C:\Users\[user]\.IntelliJIdea2017.2\config\plugins restarted IntelliJ and I suddenly had my git branch info and indexing status back. Maybe this will help someone else...
Side note
The default behavior is to show the file full-path and it will be hard to see the branch names since they're pushed all the way to the right. To solve that you can:
Go to File > Settings > Other Settings > GitToolBoxGlobal > Project View and arrange the ordering of the variables in the left pane. E.g. I use the following order: {status} {branch} {tags on head} {location}; this will display something like 3↑ 2↓ master 1.0.0 /path/to/location
Or install PathHide plugin to get rid the module path if you don't need it.
There are 2 possible scenarios of not displaying git branch name and here is how to resolve them.
1). Firstly, if your entire status bar is hidden or not display currently; So, you can enable it by easily by Tick the Status Bar option like this:
View -> Appreances -> Then Tick the Status Bar option
2).If your problem is still displaying the Status Bar in the IDE though, your GIT branch section doesn't display. Then you can use Status Bar Widget option to enable it also.
View -> Appreances -> Ststus Bar Widgets -> Git Branch