1

I have a private GitHub repo that I'd like to setup my testing server (LAMP) to automatically pull/fetch the files in the master branch and put them in my web root (/var/www).

Wouldn't it be possible to create a shell script that would cd to /var/www and then run git pull origin master? Could I do this using a CRON job?

2 Answers 2

3

Yes.

Create a shell script with something like:

#!/bin/sh
cd /var/www
git pull origin master

You can store the file wherever you like. Let's assume in /scripts/ Let's assume it's called getsite.sh

Make sure your file is executable:

chmod +x /scripts/getsite.sh

Run the command to make sure it works. I'll assume you've already run git init, and setup the repo.

/scripts/getsite.sh

Assuming it works OK, you can create a crontab entry to run it as often as you see fit:

crontab -e

You'll need an entry something along the lines of:

59 23 * * * /scripts/getsite.sh

This would run the script at 23:59 every day.

Read up on the man page for crontab if you need help with it.

0
0

The answer is yes--but you have a few different options to consider. The basic idea is chaining events together, whether you use git-hooks or rsync and cron or even Dropbox.

For more ideas, take a look at http://debuggable.com/posts/git-tip-auto-update-working-tree-via-post-receive-hook:49551efe-6414-4e86-aec6-544f4834cda3

and

http://www.turnkeylinux.org/blog/website-synchronization

Do a search for git-hooks and push/pull and you should find plenty of info.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .