The safest way to try to get what you want is to try to deserve what you want

macOS git自动补全命令分支名

Posted on By Frank·J

一、 安装 bash-completion

// 安装
brew install bash-completion

// 卸载
brew uninstall bash-completion

Homebrew官网,如果你好未安装 Homebrew 的话可以参考以下命令(以官网为准哦)

/usr/bin/ruby -e "$(curl -fsSL"


brew info bash-completion


==> Caveats
Add the following line to your ~/.bash_profile:
  [ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion


[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion
vim ~/.bash_profile

二、 拷贝文件并设置路径

访问github将’contrib/completion/’目录下的 git-completion.bash 拷贝到本地文件内(记住地址),

source <local path>/.git-completion.bash

三、 启动终端

输入 git 命令、分支名就可以自动补全了