Search code examples
bashgitgit-completion

git auto-complete doesn't prompt branch names


I tried all that mentioned in this thread, still when I double tap tab key for command git checkout I get only following suggestions

FETCH_HEAD HEAD ORIG_HEAD

whereas I am expecting branch names.

Any other suggestion to get this working?

I am on ubuutu 14.04

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

UPDATE

global gitconfig file

[user]
        email = [email protected]
        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 version

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

bash-completion details

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

Command output

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. I am facing the same issue in all other repos also.


Solution

  • I may be wrong, but I think you are trying to use a too old version of git compared to your version of git-completion.

    You can try running:

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

    If there is no output, of if there is an error, I am probably right (I expect something along the line of fatal: unknown refname: format strip=2).

    In this case, either upgrade your version of git, or replace your git-completion so that it matches your version of git. If you choose the latter, you can use this version (from git's github repository).