IntelliJ and Git Branch Name

GitIntellij Idea

Git Problem Overview


I've recently moved from Eclipse to IntelliJ. A challenge as I'm a keyboard shortcut junkie, but that isn't what I'm here about.

I miss having the git branch name shown in the package/project view.

Does anyone know of a way to configure IntelliJ to display what git branch the project is in, so I don't have to keep switching back to the terminal and checking.

Thanks.

Git Solutions


Solution 1 - Git

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]

Solution 2 - Git

Install IntelliJ Plugin "GitToolBox"

enter image description here

Solution 3 - Git

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

Status Bar option

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

State Bar Widget option

Hope this will fix your issue.

Solution 4 - Git

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

EDIT: Ignore this prompt. If you need a GIT prompt use http://volnitsky.com/project/git-prompt/

Solution 5 - Git

Coming from Eclipse, I was used to that, so I created a plugin for this:

https://plugins.jetbrains.com/plugin/7802?pr=idea

Solution 6 - Git

That setting doesn't seem to be available with the current Git integration in IntelliJ IDEA.

One workaround would be to start a fake push, because the push Window would then display the current branch.

Push Changes options

(just click cancel instead of going forward with the push:
You have the information you were looking for in the first place.)

Solution 7 - Git

  1. You have to add VCS to the project if not already done
  2. CTRL SHIFT A - opens find
  3. Type - status
  4. Select Status Setting
  5. Click on version control
  6. It would list out the unregistered projects
  7. Select your project then click on + button on the right panel
  8. If You have initialized the git in your local then it would not ask for git path.
  9. Check the other parameters as per your requirement and then apply.

Congrats, you are done provided you have enabled the status bar.

Solution 8 - Git

This is a late answer, if someone is looking for a way to see current git branch in intelliJ.

  1. Install gitbar plugin Git Bar Plugin Repo

enter image description here

  1. Enable status bar and look at the bottom right corner , which shows your current branch as well as you can switch branches from there.

enter image description here

Solution 9 - Git

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...

Solution 10 - Git

Try using git.exe from "/bin" folder

Example Image

Solution 11 - Git

Just install GitToolBox plugin.

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questiondom farrView Question on Stackoverflow
Solution 1 - GitLoKiView Answer on Stackoverflow
Solution 2 - GitR.AView Answer on Stackoverflow
Solution 3 - GitGeeganage Punsara PrathibhaView Answer on Stackoverflow
Solution 4 - Gitdom farrView Answer on Stackoverflow
Solution 5 - GitilintarView Answer on Stackoverflow
Solution 6 - GitVonCView Answer on Stackoverflow
Solution 7 - GitSivani PatroView Answer on Stackoverflow
Solution 8 - GitTitoView Answer on Stackoverflow
Solution 9 - GitJoe KeeneView Answer on Stackoverflow
Solution 10 - GitGustavo TrevisaniView Answer on Stackoverflow
Solution 11 - GitPadoView Answer on Stackoverflow