WARNING: this script is deprecated, please see git-completion.zsh
Solution 1
Might seems silly, but make sure that you source your ~/.zshrc
file (create one if it does not exists). On OSX I completely forgot that I had switched to zsh, and got the error you mentioned because I was doing source ~/.bashrc
- The easiest way to get auto-completion working is to install it through Homebrew (it will work for zsh as well as bash.):
brew install bash-completion
- Put this into your
~/.zshrc
:
# auto-completion
if [ -f /opt/local/etc/profile.d/bash_completion.sh ]; then
. /opt/local/etc/profile.d/bash_completion.sh
fi
- Save the file and do a
source ~/.zshrc
and you will be good
Solution 2
For me, I simply had copied over the contents of ~/.bash_profile
to ~/.zprofile
when migrating to zsh. I simply removed this line which was the root cause of the warning message:
source ~/.profile
Solution 3
In Git for Windows, this message is emitted during execution of the file etc/profile.d/git-prompt.sh
, if the shell is not Bash.
git-prompt.sh
sources git-completion.bash
without looking at the shell name. That file checks that it is not run by Bash, emits that warning message and exits.
Here is the link to the respective code: https://github.com/git/git/blob/master/contrib/completion/git-completion.bash#L3509
You should look inside git-completion.zsh located in the same directory near this file and follow installation instructions provided in the comments in the beginning:
# The recommended way to install this script is to make a copy of it as a
# file named '_git' inside any directory in your fpath.
#
# For example, create a directory '~/.zsh/', copy this file to '~/.zsh/_git',
# and then add the following to your ~/.zshrc file:
#
# fpath=(~/.zsh $fpath)
Related videos on Youtube
Comments
-
zianwar almost 2 years
I'm using oh-my-zsh and I get this error every time I open terminal:
WARNING: this script is deprecated, please see git-completion.zsh
is there any solution to that?
-
Nathan Basanese about 9 yearsI think this is a good question, since many times people will simply google a warning that appears in their command line.
-
-
Nathan Basanese about 9 yearsI get the following errors from my zsh: zsh:12: command not found: ___main (eval):1: no matches found: *:all-files _tags:comptags:36: can only be called from completion function _tags:comptry:55: can only be called from completion function _tags:comptags:60: can only be called from completion function _tags:comptags:67: can only be called from completion function zsh --version zsh 5.0.5 (x86_64-pc-linux-gnu) # I also use Oh My Zsh.
-
dimitarvp about 5 yearsThis solved a 2-hour struggle for me after I switched to zsh. Thank you!
-
Dani almost 5 years
_git:12: command not found: ___main _git:15: command not found: _default complete:13: command not found: compdef
-
Aleksandr Ryabov over 3 yearsIt says
git-completion.zsh:.:48: no such file or directory: _git:19: command not found: _default
at MacOS 11. -
Fowad over 3 yearsYou saved me so much time. Thank you! I just switched to macOS and you're the only person who told me to create a
~/.zshrc
-
Mauricio Crispim about 3 yearsTks bro, i am new im Mac. Tks <3
-
IgorGanapolsky about 3 yearssource: no such file or directory: /Users/myuser/.profile
-
Jas about 3 years@IgorGanapolsky Looks like
~/.profile
does not exist, so if you remove that line when copying over from~/.bash_profile
to~/.zprofile
you should not get that error -
Eaweb about 3 years@EzequielDeSimone I had to comment out "#source ~/git-completion.bash" in my zshrc to clear the warning even after following the instructions on this answer. Maybe that might help too.
-
Klas Mellbourn almost 3 yearsThe closest file I can find is
/opt/homebrew/etc/bash_completion
. But sourcing that in zsh gives lots of errors like/opt/homebrew/etc/bash_completion:59: command not found: shopt
-
Vinod Ranga over 2 yearsapple.stackexchange.com/a/381980/341466 resolve using this problem in my file is not added autoload -Uz compinit && compinit in zshrc
-
Colin Daniel over 2 yearsFor this issue, my colleague just needed to remove references to bash_completion in the
.zshrc
file. We use ohmyzsh and autocompletion is already implemented.