If I type:

rm <TAB>

I'll see possible completions almost instantly.

However, if I type:

git rm <TAB>

It'll hang for several seconds if it's in a git repo, or fail to show any completions if I'm outside of a git repo.

How can I fix this behavior?

There's nothing in my .zshrc that looks like it has to do with git :-/

  • 2
    +1 This drives me so batty I've wired my brain to not hit <TAB> when using git. Commented Aug 8, 2012 at 12:12

4 Answers 4


I finally bothered to google this and came up with this SO answer, which worked perfectly for me. Add this to .zshrc:

__git_files () { 
    _wanted files expl 'local files' _files     

There's also a deep mailing list thread here about it explaining what zsh is doing to take so long.

  • 2
    This did not work for me. I'm loading the following oh-my-zsh plugins: plugins=(git gitfast last-working-dir zeus). I loaded the above function after the plugins. Commented Nov 21, 2013 at 21:41
  • 1
    I had the same problem. Commenting to confirm success: on OSX 10.8.5, zsh 4.3.11, git 1.8.2, that .zshrc entry made all the difference. Without it, cpu regularly pinned at 100%. With it, tab completion seems about the same for git commands as any other. Thank you! :)
    – cweekly
    Commented Apr 4, 2014 at 20:34
  • Make sure you put this command before your zsh plugins, otherwise you might end up with quick autocompletion, but errors once you try to actually run the git command.
    – Simon
    Commented Apr 22, 2015 at 7:22
  • While this solves the performance issue, it also results in a completion behaviour that doesn't know anything about modified/untracked/ignored files and will happily complete any file. While this may be fine or even preferrable for some users, I prefer the solution outlined in the other answer more convenient.
    – Thomas G.
    Commented Jun 18, 2021 at 13:22
  • This worked for me on Big Sur. Commented Feb 1, 2022 at 17:46

Here's another option: the official Git zsh completion: git-completion.zsh. All you need to do is download that to ~/.zsh/_git, and make sure it's in your fpath:

fpath=(~/.zsh $fpath)

I find it interesting that this thread is mentioned in another response; I started that thread, and I wrote the official Git zsh completion as a result.


None of the existing answers worked for me (where git branch autocompletion was taking ridiculously long).

Instead, the solution for me was switching from the default git plugin to gitfast.

I got this from a bit of a roundabout way, by first installing oh-my-zsh and then enabling the plugin. (There may be a better way to do this)


  1. Install oh-my-zsh via sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" (based on instructions from original repo)
  2. In your ~/.zshrc file, replace the line plugins=(git) with plugins=(gitfast) to switch to the gitfast plugin.

I was able to fix this issue by using a combination of @FelipeC's answer and this answer from a similar Stack Overflow question.

When I only did what @FelipeC suggested, I then got the error mentioned in the referenced Stack Overflow question. Following the instructions in the Stack Overflow answer fixed the error and made git auto completion far more responsive.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .