Git Push on Commit

Configure git to automatically push after you’ve done a commit. This is great for creating backups and staying in sync with other developers.

Git Project

Navigate to your git repository and look for a folder called “.git”. The .git folder is a hidden folder so if you are not able to see it make sure that your operating system is not hiding hidden files.

Open the hooks folder and create a new file called post-commit (don’t use any file extensions). Put the following code into the post-commit file that you just created.

#!/bin/sh
git push origin master

Now that you’ve added the code to your git hooks, you’ve told git to push any changes on commit.