You don't explain what software is running on your local server, but assuming this is some flavor of UNIX/Linux/macOS and you have crontab
access, the easiest thing is probably to just schedule a cron job to pull updates.
A command like the following will schedule a git update every 60 seconds, logging the output to a file:
echo '* * * * * cd $HOME/path/to/git/workdir && git pull -q --ff-only >> update-log 2>&1' | crontab
Note 1: This assumes your user currently has an empty crontab on the server, if you don't then you should instead use crontab -e
to manually append the directive to your existing crontab.
Note 2: You'll need to ensure your account on the server has permission to access the BitBucket repo without a tty connection (e.g. without SSH agent forwarding), so you might need to fiddle with authentication to set that up (which is beyond the scope of this answer). For a public BitBucket repo, cloning via HTTPS without a user name is probably the simplest approach, since no authentication is required.
Note 3: The first *
in the directive above can be adjusted to select a different polling frequency, e.g. 0,15,30,45
for every 15 minutes. If you omit the 2>&1
then you should get an email for any errors (assuming SMTP is configured on the server).
Note 4: The git
command embedded above assumes you never rewrite history in the upstream git repo or manually modify the local directory. If either is a possibility, then you might instead want to use git pull -q --rebase
or even git fetch && git reset --hard '@{upstream}'