user507139
user507139

Reputation:

How to update my server files from a git repo automatically everyday

I am a noob in these server related work. I am writing some PHP code in my local system and has been updating my repo in github regularly. Each time I want to test my application, I copy all the files from my local system onto my server through FTP and then do it. Now I want to know whether is there a way to automatically make the commits that I make to reflect in the files in the server. Is there a way to automatically make the server get the files from the repo periodically? (say, once everyday).

Can this be done other way, like when I make a push from my local machine, the repo gets updated and in turn the files on the server also get updated?

My Server Details: Apache 2.2.15, Architecture i686 with Linux Kernel 2.6.18-194.32.1.el5

Upvotes: 3

Views: 4791

Answers (3)

raylu
raylu

Reputation: 2816

In addition to cronjobs, you can use a post-receive hook: http://help.github.com/post-receive-hooks/

Upvotes: 2

Tommy
Tommy

Reputation: 1267

If you have cronjobs you can use them. First set up the repository on your server. Then you can set up the cronjob, choose a time in which it should be executed, and then in the cronjob execute the following command:

cd your/repository/folder; git pull master origin

Upvotes: 1

Seb
Seb

Reputation: 5842

Perhaps explore the git archive command, which you can use to get a zip file or similar of your code. You could then perhaps use a script to copy that to your (other) server?

git archive --format=zip --output=./src.zip HEAD

will create a zip file called src.zip from the HEAD of your repo

More info:

Upvotes: 0

Related Questions