5

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 = 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 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 <spearce@spearce.org>
# 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.

Kishor Pawar
  • 3,386
  • 3
  • 28
  • 61
  • Please provide a [mcve], so that one can reproduce your issue. With your current question's content, I have to read your link, hope you did _exactly_ what it says and come to the conclusion, that I can't reproduce it... – Clijsters Feb 07 '18 at 08:40
  • @Clijsters, I exactly did the same things mentioned in that thread, I had done those same things already on my older dev machines. The only difference in my current repo is, it was copied back from another machine on the network. – Kishor Pawar Feb 07 '18 at 09:30
  • Just to be clear... `git fetch` works w/o any problems and git branch shows your branches? – Clijsters Feb 07 '18 at 09:36
  • Yes, all git commands work fine. only I don't get the branch names in suggestions. – Kishor Pawar Feb 07 '18 at 09:37
  • Can you provide the output of `git branch -a`? – silel Feb 07 '18 at 10:48
  • @silel there are a hell lot of branches man. Do I really need to put it here? – Kishor Pawar Feb 07 '18 at 10:50
  • Probably not, as long as you make sure `git branch` sees some. On the other hand it might be useful to other users to see an abbreviated version of the output. If the repo is public you also might want to mention its name. It would probably also help to show the version of git you are running (`git --version`) as well as the version of the `bash-completion` package or whatever its name is on ubuntu. – silel Feb 07 '18 at 12:00
  • @silel my repo is private, other information I updated in question. – Kishor Pawar Feb 07 '18 at 12:07
  • Alright, I took a look at the git-completion.bash packaged with version 1.9.1 of git and it looks like the main command it internally uses to complete `git checkout` is the following: `git --git-dir=".git" for-each-ref --shell --format="%(refname:short)" refs/tags refs/heads refs/remotes` Can you try it and tell us the result? – silel Feb 07 '18 at 12:28
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/164692/discussion-between-kishor-pawar-and-silel). – Kishor Pawar Feb 07 '18 at 12:42
  • Do you get autocomplete of get commands? If you type `git check`, does it complete to `git checkout`? – Matt Feb 07 '18 at 13:20
  • And if not, did you include the `git-completion.bash` script properly? You have to source the file in your `.bashrc` or `.profile` : `source ${GIT_HOME}/etc/bash_completion.d/git-completion.bash` – Matt Feb 07 '18 at 13:24
  • @Matt "yes" to both of your questions. – Kishor Pawar Feb 07 '18 at 13:28
  • Do you have by any chance the var `GIT_COMPLETION_CHECKOUT_NO_GUESS` set? – Matt Feb 07 '18 at 15:09
  • @Matt, No. I checked my `env` variables. – Kishor Pawar Feb 08 '18 at 04:59

1 Answers1

3

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).

silel
  • 567
  • 2
  • 10
  • Awesome Silel!!! I preferred downgrading `git-completion` script. I copied the script from a source you provided and saved it in `/home` and added the path to `.bashrc` and it worked. Thanks again for teaching a new thing today. – Kishor Pawar Feb 08 '18 at 05:27
  • @KishorPawar My pleasure =) – silel Feb 08 '18 at 09:29
  • This solved my problem perfectly. Stoked I don't have to upgrade git. Note: I'm on 1.8.3.1 – caltangelo Oct 16 '18 at 18:59