Update Apache Server with Git Pull

让人想犯罪 __ 提交于 2021-02-05 11:15:11

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!