# Tab complete Git commands and branches

Here’s a quick post on the awesomeness of tab completion, and how it can be
applied to Git commands and branch names.

> 👉 **See also:** [my post on fish shell](/how-to-install-and-use-fish-shell),
> fish has awesome autocomplete built in.

There’s a little helper app called `git-completion.bash`. Grab it to your home
dir:

```shell
$ curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash
```

Then add the following to your `.bash_profile`:

```bash
if [ -f ~/.git-completion.bash ]; then
  . ~/.git-completion.bash
fi
```

If you now type `git<tab>`, a hoard of commands will pop up:

```shell
$ git <tab>
add                  clean                gc                   p4                   selfupdate
alias                clone                get-tar-commit-id    pull                 send-email
am                   column               grep                 pull-request         shortlog
annotate             commit               help                 push                 show
apply                compare              imap-send            rebase               show-branch
archive              config               init                 reflog               stage
bisect               create               instaweb             release              stash
blame                describe             interpret-trailers   relink               status
branch               diff                 issue                remote               submodule
bundle               difftool             log                  repack               subtree
checkout             fetch                merge                replace              svn
cherry               filter-branch        mergetool            request-pull         tag
cherry-pick          fork                 mv                   reset                verify-commit
ci-status            format-patch         name-rev             revert               version
citool               fsck                 notes                rm                   whatchanged
```

To view all your branches in a give repo, for example, start with `branch` and
hit tab:

```shell
$ git branch <tab>
FETCH_HEAD       new-security-page       origin/add-language-to-support
HEAD             new-security-page-bu    origin/master
ORIG_HEAD        new-stuff               origin/new-js
linted-js        old-master              origin/new-stuff
master           old-stuff
new-js           origin/HEAD
```

As you can see, the example repo has a lot of badly named feature branches.
