0

My current set up is as follows:

  • I have a laptop in which I like to write my website's code
  • I have a raspberry pi running Apache which will serve my website's code as long as it is in /var/www/html
  • I have clone a repository of my website onto the raspberry pi in Directory A.

I want to create a git hook so that when I pull my code the code updates in /var/www/html

I have tried creating both a post-merge and post-receive hook using the following code:

#!/bin/bash git --work-tree=/var/www/html --git-dir=DIRECTORY A

But it does not seem to work. Any ideas?

cbaylor
  • 38
  • 6
  • In which repository do you pull the code? In which repository do you install the hooks? – ElpieKay Jul 20 '20 at 03:07
  • I would pull the code on the server (ie the raspberry pi) and I installed the hooks on the server. If there is a different way, I would be happy to do that as well. I am very much a noob with this. – cbaylor Jul 20 '20 at 14:06

1 Answers1

0

The full command would be, in a post-receive hook:

git --work-tree=/var/www/html --git-dir=DIRECTORYA restore -- .
                                                   ^^^^^^^

Assuming you have a Git 2.23+, Q3 2019, or, if not:

git --work-tree=/var/www/html --git-dir=DIRECTORYA checkout -- .
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250