Autocomplete in almost every known shell is spoiled me, which is why I’d expect it to do the same for git. Sadly, it doesn’t come packaged with the default git installation on Mac OS X (El Capitan).
1. Download the git-completion.bash
script and store it a known location
curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 57021 100 57021 0 0 31591 0 0:00:01 0:00:01 --:--:-- 31590
2. Add the script to your .profile
if [ -f ~/.git-completion.bash ]; then . ~/.git-completion.bash fi
3. You are done.
Hitting tab after git command now shows
$git add bundle config gc log push reset stash wtf am checkout describe get-tar-commit-id merge rebase revert status annotate cherry diff grep mergetool reflog rm submodule apply cherry-pick difftool help mv relink send-email subtree archive citool fetch imap-send name-rev remote shortlog svn bisect clean filter-branch init notes repack show tag blame clone format-patch instaweb p4 replace show-branch verify-commit branch commit fsck interpret-trailers pull request-pull stage whatchanged