Autocompletion

Git comes with built-in support for auto-completion of Git commands for the bash and zsh shells. So if you use either of these shells, you can enable the auto-completion feature and let the <tab> option help you complete commands.

Getting ready

Generally, the auto-completion feature is distributed with the Git installation, but it is not enabled by default on all platforms or distributions. To enable it, we need to find the git-completion.bash file distributed/installed with the Git installation.

Linux

For Linux users, the location may vary depending on the distribution. Generally, the file can be found at /etc/bash_completion.d/git-completion.bash.

Mac

For mac users, it can generally be found at /Library/Developer/CommandLineTools/usr/share/git-core/git-completion.bash ...

Get Git: Mastering Version Control now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.