I know I'm probably an outlier, but I'm terrible at consistently committing to Git yet still use it as my #1 version control / core repo solution.
The interface and experience using Git as a single source-of-truth for your project is tough to beat.
So that said, I personally use a very simple Crontab solution to automatically push 'Auto-Commits' every 20 minutes. The comment on each automatic push is identical: 'Automatic Commit.'
This works GREAT (for me), specifically on projects where I'm the solo / primary contributor.
I prefer to use VSCode's SSH Remote option to work directly on a staging server, so setting up Git to automatically back-up the project every 20 minutes protects my project files and history.
The beauty of this solution is Git will only push a new commit if changes have been made. Also, I can still manually push new commits at any time and easily find those 'milestones,' because the auto-commits are all labeled 'Automatic Commit.'
To set up a similar workflow: (Linux only):
- Important: set up Git Credential Storage and push a manual commit before completing the steps below. E.g., run this in your project folder where your git repo is:
git config credential.helper store, then push a commit. This stores your credentials so the Cron job doesn't have to log-in. (Which it can't, because it's running in the background).
- Then, run this command in the terminal:
crontab -e
- If prompted, select the Nano editor (user-friendly) or Vim if you prefer. Add the line below to the bottom of the file.
*/20 * * * * cd /path/to/project/git/location && git add . && git commit -m "Automatic Commit" && git push origin master
You'll now see automatic commits in your Git repo (but ONLY if changes have been made to the project!).
Welcome to the future. Where Git is used completely the wrong way... but it feels good.