Add Git Autocomplete to Terminal

A nifty edition to the git command line is autocomplete. First, get the git completion script:

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

Then edit your ~/.bash_profile file to add the following code:

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

(go here for help on editing your .bash_profile)

That’s it. Now you can type git and press Tab twice to get an autocomplete list of commands.

credit:

http://apple.stackexchange.com/questions/55875/git-auto-complete-for-branches-at-the-command-line/55886#55886

http://code-worrier.com/blog/autocomplete-git/

How to Edit Your .bash_profile File

The bash_profile file is a hidden file that contains various settings and preferences that are run on startup for Terminal, including the PATH.

It’s actually super easy to edit. You simply need to open it in your favorite text editor. (I use Sublime Text) For example, if you are in your home directory, you can run

sublime .bash_profile

If you’re not in your home directory, add ~/ in front of it:

sublime ~/.bash_profile

Now you will have your .bash_profile file open in your text editor, and you can edit at will and save.

See, pretty easy!

credit: http://natelandau.com/my-mac-osx-bash_profile/