A small tool to automatically pull Git repositories on a given interval using cron or Windows Task Scheduler. Uncommitted changes are preserved and merged as possible.
- Install Node.js v22+ and make sure Git is installed on your machine.
- Place the repository contents (either cloned or unzipped) somewhere it won't move. I recommend creating a folder inside
$HOME/.config, but any location will work. - Rename the
config.example.jsonfile toconfig.jsonto fit your cloned Git repository paths. You can add multiple Git repositories inside a single base directory using thebasePathanditemskeys, and any number of base folders by adding more items to the array. Seeconfig.example.jsonfor a more comprehensive example of the schema.
To add the script to your crontab, run this command in any shell:
crontab -ePaste 0 * * * * /usr/local/bin/node /path/to/autopull/index.js > /dev/null in the file and save its contents.
Create a new task in the Task Scheduler that runs at your desired interval. Set the action to run wscript.exe with the argument being the full path to the runScript.vbs file.
By default, your repositories will be pulled every hour. If you want to adjust this interval, change the schedule expression at the start of the line to whatever interval you want (you can access the schedule by running crontab -e again). This website is a handy tool for generating cron intervals.
To match the cron schedule, set the Trigger to "Daily" and repeat the task every 1 hour for a duration of "Indefinitely".