Git is pre-installed on both OSX and Linux, but in case it is not, it is very easy to install.

Make sure Homebrew is installed, by following this earlier post.

Check if it is installed

To check if it is installed enter the following command at the terminal:

git --version

If you see anything come up (i.e. no error), for example

git version 2.15.1 (Apple Git-101)

then, as you can guess, Git is installed.

Installing Git with Homebrew

Check that Homebrew is up to date:

brew update

And now install Git:

brew install git

That's it - very quick and easy!

Checking Git installation

If you installed Git with brew, if you check the version using

git --version

you will probably get something like

git version 2.17.0

(note that Apple is not mentioned) and if you try

which git

you should get


Nice Git Commit Display

Run the three commands from the command line for nice display shortcuts:

git config --global alias.lgb "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset%n' --abbrev-commit --date=relative --branches"
git config --global alias.lola "log --graph --all --decorate --oneline --abbrev-commit"
git config --global alias.lgo "log --all --pretty='%C(yellow)%h%Creset %C(auto)%d%Creset  %s %C(cyan)%ci%Creset' --date-order --max-count=10"

Set Vim as editor

Run the following command to set Vim as the default editor for commits:

git config --global core.editor "vim"

For more tips, see the other posts in the Git section.