问题
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?
回答1:
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 -- .
来源:https://stackoverflow.com/questions/62987378/update-apache-server-with-git-pull