3

How to remove the fetch autocomplete feature, but only after the colon (:), on git?

I mean, after I type

$ git fetch origin m<tab>

, it autocompletes to

$ git fetch origin master:master

, and I want to autocomplete to just

$ git fetch origin master

, without the 'colon part' (like the previous versions of git).

Most times I'm already on master - or whatever branch, and I don't want to merge the remote branch into my local branch like this.

Thanks!

isherwood
  • 58,414
  • 16
  • 114
  • 157
Juliano A. Felipe
  • 574
  • 1
  • 7
  • 15

1 Answers1

5

Thanks clmno for pointing this out.

I edited the file /usr/share/bash-completion/completions/git, in the __git_complete_remote_or_refspec () function, commenting the following lines:

case "$cmd" in
  fetch)
    #if [ $lhs = 1 ]; then
    #  __gitcomp_nl "$(__git_refs2 "$remote")" "$pfx" "$cur_"
    #else
      __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" # leave this uncommented
    #fi
    ;;

And it works as I want expect.

Juliano A. Felipe
  • 574
  • 1
  • 7
  • 15