0

I created a git repository on my webserver to manage my website sources and I want to automatically copy all updated files into my /srv/http directory so after every push to the master branch my website updates.

How can I do this?

Colin 't Hart
  • 7,372
  • 3
  • 28
  • 51
salbeira
  • 2,375
  • 5
  • 26
  • 40
  • I write my code on my Desktop PC or Laptop and need the webserver to test changes to my php code - as such it is a great hassle to always access my webserver's /srv/http via ftp and copy the files over - I would much rather automate this by simply pushing the files via git and then automate the process of updating the files on the actual server directory – salbeira Oct 21 '13 at 00:32
  • There are plenty of different [auto-deploy examples Out There](https://www.google.com/#q=git+deploy+hook). The main issues are deciding what gets deployed where, and how to handle permission issues. – torek Oct 21 '13 at 03:33

1 Answers1

0

While there are many example, as noted by torek, note that:

  • most involves a post-receive hook
  • you can filter on the branch being pushed in such an hook.

See for instance "how to process files on a branch in post-receive hook in git".

while read oldrev newrev ref
do
  branch=`echo $ref | cut -d/ -f3`

  if [ "master" == "$branch" ]; then
    ...
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250