如何在 Mac OS git 中启用分支提示?

How to enable branch hints in Mac OS git?

在 windows 中,当我使用 git bash 时,例如想结账到某个分行,点击 tab 会显示所有分行,或者填写分行名称如果我已经写了一部分。在我的 Mac OS 中,当我从我的终端使用 git 时,这些功能被禁用。有没有办法启用它们,如何启用?

您必须安装 git-autocomplete which can be get with homebrew:

  1. 安装Git和bash-完成:brew install git bash-完成(注意:如果此安装失败并出现404错误,并且您已经安装了 git,只需删除此 brew install 的 git 部分)

  2. 将 bash-completion 添加到您的 .bash_profile:

if [ -f `brew --prefix`/etc/bash_completion ]; then
    . `brew --prefix`/etc/bash_completion
fi

注意:同样的 git completion 在 Git 2.11(2016 年第 4 季度)

中变得更加完整

参见 commit 49416ad (24 Aug 2016) by Chris Packham (cpackham)
(由 Junio C Hamano -- gitster -- in commit a229a30 合并,2016 年 10 月 10 日)

The command-line completion script (in contrib/) learned to complete "git cmd ^mas<HT>" to complete the negative end of reference to "git cmd ^master".