git命令自动补全

git安装好后发现命令不能自动补全于是搜了很多方法,先按博客里面的方法试了下:

1.下载配置文件 git clone git://git.kernel.org/pub/scm/git/git.git

   2.cp git/contrib/completion/git-completion.bash ~/.git-completion.bash

   3.在.bashrc中添加  source ~/.git-completion.bash

但是在执行第一步的时候就遇到了问题,一直报错,尝试改了DNS地址也还是不行,于是就手动去官网下载下来然后复制到根目录下,接着执行第三步然后重启终端,尝试用tab键补齐命令,但是还是不成功,显示如下

$ git commi <tab>

Unknown option: --list-cmds=list-mainporcelain,others,nohelpers,alias,list-complete,config
usage: git [--version] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           [-c name=value] [--help]
           <command> [<args>]

git: 'commi' is not a git command. See 'git --help'.

Did you mean one of these?
        commit
        config

https://www.git-scm.com/book/en/v2/Customizing-Git-Git-Configuration中发现要将help.autocorrect 设为1才会自动更正

git config --global help.autocorrect 1

然而设置好后还是出现和之前一样的情况,接着在网上找办法,最终在https://github.com/yszheda/wiki/wiki/git-tips#bash_autocomplete_Unknown_option_listcmdslistmainporcelainothersnohelpersaliaslistcompleteconfig中找到了解决办法

source /etc/bash_completion.d/git
# or
source /usr/share/bash-completion/completions/git

输入命令行再次尝试就可以了.

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值