Git bash 无法看到我当前工作的当前分支

Git bash 无法看到我当前工作的当前分支,git-bash,.bash-profile,Git Bash,.bash Profile,我正在使用git,这就是我的bash_配置文件的样子 "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function if [ -f /usr/local/etc/bash_completion.d/git-completion.bash ]; then . /usr/local/etc/bash_completion.d/git-completion.bash fi PS1='

我正在使用git,这就是我的bash_配置文件的样子

"$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
if [ -f /usr/local/etc/bash_completion.d/git-completion.bash ]; then
  . /usr/local/etc/bash_completion.d/git-completion.bash
fi   
PS1='\[\033[32m\]\u@\h\[\033[00m\]:\[\033[36m\]\w\[\033[31m\]$(__git_ps1)\[\033[00m\]\$ '
GIT_PS1_SHOWDIRTYSTATE=true
我以前经常看到我现在所在的分支的名称,但现在不再显示了。
项目名称(当前分支机构名称)

它总是显示
”-bash:\uu git\u ps1:未找到命令“


我可以在配置文件中更改什么?

您遇到的问题是git-completion.bash很可能不在您要查找它的位置

这意味着:

if [ -f /usr/local/etc/bash_completion.d/git-completion.bash ]; then
很可能是失败了

尝试将其更改为指向git安装目录中的contrib目录。例如,如果git安装在/usr/local/git中,那么

if [ -f /usr/local/git/contrib/completion/git-completion.bash ] ; then
    . /usr/local/git/contrib/completion/git-completion.bash
fi