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
The hook we are interested in is
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:
- Execute each time you commit something into your repository.
- Avoid doing anything if the commit is made during a rebase or
- Push to a remote named
origin (or whichever one you
UPSTREAM shell variable to point).
- Create or update a remote reference that matches the branch name
that’s currently checked out.
Copy and paste the following script into a file named
.git/hooks/post-commit in your repository directory.