IntelliJ and Git Branch Name

2020-05-18 04:20发布

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.

10条回答
Melony?
2楼-- · 2020-05-18 04:54

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/

查看更多
淡お忘
3楼-- · 2020-05-18 04:57

Try using git.exe from "/bin" folder

Example Image

查看更多
可以哭但决不认输i
4楼-- · 2020-05-18 04:58

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

查看更多
▲ chillily
5楼-- · 2020-05-18 04:59

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]
查看更多
男人必须洒脱
6楼-- · 2020-05-18 04:59
  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.

查看更多
姐就是有狂的资本
7楼-- · 2020-05-18 05:00

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

查看更多
登录 后发表回答