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

Kis*_*war 5 git bash git-completion

我尝试了该线程中提到的所有内容,但当我双击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
Run Code Online (Sandbox Code Playgroud)

更新

全局 gitconfig 文件

[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
Run Code Online (Sandbox Code Playgroud)

git版本

kishor@kishor-ThinkCentre-E73:~$ git version
git version 1.9.1
Run Code Online (Sandbox Code Playgroud)

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.  
Run Code Online (Sandbox Code Playgroud)

命令输出

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
Run Code Online (Sandbox Code Playgroud)

PS 我在所有其他存储库中也面临同样的问题。

sil*_*lel 3

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

您可以尝试运行:

git for-each-ref --format="(refname:strip=2)" refs/heads/*
Run Code Online (Sandbox Code Playgroud)

如果没有输出,或者如果有错误,我可能是对的(我期望出现类似的情况fatal: unknown refname: format strip=2)。

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