3

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

Marc W
  • 19,083
  • 4
  • 59
  • 71

3 Answers3

2

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

raylu
  • 2,630
  • 3
  • 17
  • 23
1

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
Tommy
  • 1,277
  • 1
  • 11
  • 22
  • Thank you this method is simple and suitable to my task. –  Apr 11 '11 at 07:46
  • @Arun Mozhi Please consider accepting my answer, if it solved your question. – Tommy Apr 11 '11 at 09:29
  • I think a git init needed to be done once. If you could tell me how, I will surely accept it. –  Apr 16 '11 at 11:54
  • 1
    @Arun Mozhi You could either ssh to the server, and execute the git clone command, or put it in another cronjob, which you let run only once, if you don't have ssh access to your server. – Tommy Apr 16 '11 at 12:07
0

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:

Community
  • 1
  • 1
Seba Illingworth
  • 5,672
  • 3
  • 27
  • 25