Thursday, August 11, 2016

Synchronize a Git repository to another Git repository automatically

To synchronize a Git repository to another Git repository automatically, create a script called `sync2bitbucket.sh` as follows:

cd /home/izeye/workspaces/izeye/ask-anything
git pull >> /home/izeye/workspaces/izeye/ask-anything/sync2bitbucket.log 2>&1
git push bitbucket >> /home/izeye/workspaces/izeye/ask-anything/sync2bitbucket.log 2>&1

and add an execution permission to it as follows:

chmod +x sync2bitbucket.sh

Add a job to Cron as follows:

crontab -e

* * * * * /home/izeye/workspaces/izeye/ask-anything/sync2bitbucket.sh

No comments:

Post a Comment