[英]IntelliJ and Git Branch Name
I've recently moved from Eclipse to IntelliJ.我最近从 Eclipse 转移到了 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.我想念包/项目视图中显示的 git 分支名称。
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.有谁知道配置 IntelliJ 以显示项目所在的 git 分支的方法,这样我就不必一直切换回终端并进行检查。
Thanks.谢谢。
As of IntelliJ 11 the current Git branch is displayed in the bottom right corner of the status bar.从 IntelliJ 11 开始,当前 Git 分支显示在状态栏的右下角。 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:要启用
status bar
,请按照以下步骤操作:
View --> Appearance --> Status Bar [and click to enable/disable]
There are 2 possible scenarios of not displaying git branch name and here is how to resolve them.不显示 git 分支名称有两种可能的情况,这里是解决它们的方法。
1). 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. 2). 如果您的问题仍然是在 IDE 中显示状态栏,那么您的 GIT 分支部分不会显示。 Then you can use Status Bar Widget option to enable it also.
然后您也可以使用 Status Bar Widget 选项来启用它。
View -> Appreances -> Ststus Bar Widgets -> Git Branch
Hope this will fix your issue.希望这会解决您的问题。
Coming from Eclipse, I was used to that, so I created a plugin for this:来自 Eclipse,我已经习惯了,所以我为此创建了一个插件:
https://plugins.jetbrains.com/plugin/7802?pr=idea https://plugins.jetbrains.com/plugin/7802?pr=idea
As IntelliJ cannot show be my branch I found a way to add the branch to my bash prompt in the terminal.由于 IntelliJ 无法显示我的分支,我找到了一种方法将分支添加到终端中的 bash 提示符中。 I've added this to my.bashrc file and I get a nice real-time branch indicator.
我已将它添加到 my.bashrc 文件中,并且我得到了一个很好的实时分支指示器。
#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/
如果您需要 GIT 提示符,请使用http://volnitsky.com/project/git-prompt/
That setting doesn't seem to be available with the current Git integration in IntelliJ IDEA .该设置似乎不适用于 IntelliJ IDEA 中当前的 Git 集成。
One workaround would be to start a fake push, because the push Window would then display the current branch.一种解决方法是启动假推送,因为推送窗口随后会显示当前分支。
(just click cancel instead of going forward with the push: (只需单击取消而不是继续推送:
You have the information you were looking for in the first place.)您首先拥有您正在寻找的信息。)
Congrats, you are done provided you have enabled the status bar.恭喜,如果您启用了状态栏,您就完成了。
This is a late answer, if someone is looking for a way to see current git branch in intelliJ.这是一个迟到的答案,如果有人正在寻找一种方法来查看 intelliJ 中的当前 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.我遇到了一个问题,即在迁移到 IntelliJ 2017.2 后我没有 git 栏或索引状态 - 我的问题归结为“代码大纲”插件。 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.我从
C:\Users\[user]\.IntelliJIdea2017.2\config\plugins
中删除了它的 jar 文件,重新启动了 IntelliJ,我突然恢复了 git 分支信息和索引状态。 Maybe this will help someone else...也许这会帮助别人......
Try using git.exe from "/bin" folder尝试使用“/bin”文件夹中的 git.exe
Just install GitToolBox plugin.只需安装GitToolBox插件。
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:
要解决这个问题,您可以:
File > Settings > Other Settings > GitToolBoxGlobal > Project View
and arrange the ordering of the variables in the left pane.File > Settings > Other Settings > GitToolBoxGlobal > Project View
并在左窗格中安排变量的顺序。 Eg I use the following order: {status} {branch} {tags on head} {location};3↑ 2↓ master 1.0.0 /path/to/location
3↑ 2↓ master 1.0.0 /path/to/location
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.