How to enable branch hints in Mac OS git?

1.3k views Asked by At

In windows, when I use git bash, and for example want to to checkout to some branch, hitting tab shows me all the branches, or fills the branch name if I have written part of it. In my Mac OS, when I use git from my terminal, these features are disabled. Is there a way to enable them, and how?

2

There are 2 answers

1
Thomas Ayoub On BEST ANSWER

You have to install git-autocomplete which can be get with homebrew:

  1. Install Git and bash-completion: brew install git bash-completion (Note: If this install fails with a 404 error, and you already have git installed, just remove the git part of this brew install)

  2. Add bash-completion to your .bash_profile:

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

Note: that same git completion just got more complete with Git 2.11 (Q4 2016)

See commit 49416ad (24 Aug 2016) by Chris Packham (cpackham).
(Merged by Junio C Hamano -- gitster -- in commit a229a30, 10 Oct 2016)

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".