Disable auto-completion of remote branches in Git Bash?

后端 未结 9 1491
广开言路
广开言路 2020-11-30 01:59

I\'m working on a fairly large git repo with a couple of thousand (remote) branches. I am used to using auto-completion (using [TAB]) in the console (Git Bash in that case),

9条回答
  •  执笔经年
    2020-11-30 02:17

    Carey Metcalfe wrote a blog post containing a solution that also edits the auto-completion function, but with slightly newer code than other answers. He also defines an alias checkoutr that keeps the old auto-complete behavior in case it’s ever needed.

    In short, first create the checkoutr alias with this command:

    git config --global alias.checkoutr checkout
    

    Then find git-completion.bash, copy the _git_checkout function into your shell’s RC file so that it gets redefined, and inside that function, replace this line:

    __git_complete_refs $track_opt
    

    with the following lines:

    if [ "$command" = "checkoutr" ]; then
        __git_complete_refs $track_opt
    else
        __gitcomp_direct "$(__git_heads "" "$cur" " ")"
    fi
    

    See the blog post for more details and potential updates to the code.

提交回复
热议问题