简体   繁体   中英

Git tab completion stopped working on remote branches

I've updated git to its latest version (2.29.0) and my using ZSH 5.8.

I used to switch between branches with git checkout remote_br<tab> to quickly switch between branches, even if the branch is only a remote one atm. I've seen git has made a lot of changes regarding switch/checkout recently , the thing is my autocompletion on remote branches doesn't work anymore (with checkout or switch).

I've tried to add the latest version of contrib/completion/git-completion.zsh to my zsh but I still have my issue. Am I missing something here ?

I've been looking into this for the last few hours and have identified the regression.

The regression occurs in 6880779 .

To temporarily resolve this: replace your git-completion.bash file (mine's located at /usr/local/share/zsh/site-functions/git-completion.bash ) with https://github.com/git/git/blob/688077910bdfbd502cb59c9c48a2af2c97d8b67b~1/contrib/completion/git-completion.bash

To really resolve this, upvote my git PR and help get it merged! ( https://github.com/git/git/pull/902 )

Try the following patch:

--- a/git-completion.zsh
+++ b/git-completion.zsh
@@ -97,6 +97,11 @@ __gitcomp_direct ()
        compadd -Q -S '' -- ${(f)1} && _ret=0
 }
 
+__gitcomp_direct_append ()
+{
+       __gitcomp_direct "$@"
+}
+
 __gitcomp_nl ()
 {
        emulate -L zsh

In general it's better to report bugs to the git mailing list , however, I'm the maintainer of the zsh code, which is more up to date in my fork: git-completion .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM