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.
This tool requires Node.js (any reasonably recent version should be fine). It also requires git (obviously).
First, place the repository contents (either cloned or unzipped) somewhere it won't move (I recommend creating a folder inside $HOME/.config).
Rename the config.example.json file to config.json to fit your cloned Git repository paths. You can add multiple Git repositories inside a single base directory using the basePath and items keys, and any number of base folders by adding more items to the array. See config.example.json for 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".