Use Git hooks to automatically push after every commit

A Git hook is a shell script that is invoked at specific points during some Git operations. They are documented in the Git book.

The hook we are interested in is post-commit (documented here). It gets run after a new commit is made. This is exactly when we want to try and update our remote.

Our hook will:

Copy and paste the following script into a file named .git/hooks/post-commit in your repository directory.