git 自动完成不提示分支名称

git auto-complete doesn't prompt branch names

我尝试了 this 线程中提到的所有方法,但当我双击 tab 命令键 git checkout 时,我仍然只得到以下建议

FETCH_HEAD HEAD ORIG_HEAD

而我期待的是分支名称。

还有其他建议可以使它正常工作吗?

我在 ubuutu 14.04

Distributor ID: Ubuntu
Description:    Ubuntu 14.04.5 LTS
Release:    14.04
Codename:   trusty

更新

全局git配置文件

[user]
        email = abc@zxc.com
        name = Abc Zxc
[credential]
        helper = cache --timeout=3600
[filter "lfs"]
        process = git-lfs filter-process
        required = true
        clean = git-lfs clean -- %f
        smudge = git-lfs smudge -- %f
[diff]
        tool = meld
[merge]
        tool = meld
[difftool]
        prompt = false

git版本

kishor@kishor-ThinkCentre-E73:~$ git version
git version 1.9.1

bash-完成详情

# bash/zsh completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.  

命令输出

git --git-dir=".git" for-each-ref --shell --format="%(refname:short)" refs/tags refs/heads refs/remotes

'160117_whole_flow_demo'
'170109_aws_mgmt_plane'
'170123_django_angular_lib'
'170124_authentication'
'170125_merging_html'
'170206_code_integration'
'170208_ng_code_snippets'
'170214_user_mapping_and_dropdown'
... and so on

P.S。我在所有其他回购协议中也面临同样的问题。

我可能是错的,但我认为与您的 git-completion 版本相比,您正在尝试使用太旧的 git 版本。

你可以试试运行:

git for-each-ref --format="(refname:strip=2)" refs/heads/*

如果没有输出,或者如果有错误,我可能是对的(我预计会出现类似 fatal: unknown refname: format strip=2 的结果)。

在这种情况下,要么升级您的 git 版本,要么替换您的 git-completion,使其与您的 git 版本匹配。如果选择后者,则可以使用 this version(来自 git 的 github 存储库)。