如何设置 git 挂钩 HTTP 协议以在远程服务器上自动开发
How to set git hook over HTTP protocol to Automate development on a remote server
我正在使用 git 进行版本控制,我想自动化 git 以自动将任何协作者推送到远程服务器的所有内容推送到远程服务器,如果我想重新执行此操作ssh,我必须在我的服务器中添加所有协作者 ssh-keys,但我不想让他们访问服务器,所以我想通过 HTTP 设置这个 git 挂钩,这样每个人都可以推送到远程通过 HTTP 协议的服务器
到目前为止,我所做的是设置一个 git 挂钩,我使用 Nginx 作为 Web 服务,并将裸 git 存储库放在
/var/www/html/test_repo
我在本地计算机上设置了我的 git 遥控器,如下所示:
git remote add test http://ServerIp/test_repo
但它给了我这个错误:
fatal: repository 'http://ServerIp/test_repo/' not found
您的 NGiNX 需要调用 /usr/lib/git-core/git-http-backend
以便 git 正确响应 clone/pull 命令。
例如 this answer:最好在 URL 路径中设置一个文件夹来跟踪 git 回购。
listen 80;
server_name myhostname;
access_log /var/log/nginx/git.access.log;
error_log /var/log/nginx/git.error.log;
gzip off;
location ~ /git(/.*) {
...
}
因此 git 回购协议的 URL 将是 http://ServerIp/git/test_repo,即使 fastcgi_param GIT_PROJECT_ROOT
参数将是 /var/www/html
我正在使用 git 进行版本控制,我想自动化 git 以自动将任何协作者推送到远程服务器的所有内容推送到远程服务器,如果我想重新执行此操作ssh,我必须在我的服务器中添加所有协作者 ssh-keys,但我不想让他们访问服务器,所以我想通过 HTTP 设置这个 git 挂钩,这样每个人都可以推送到远程通过 HTTP 协议的服务器
到目前为止,我所做的是设置一个 git 挂钩,我使用 Nginx 作为 Web 服务,并将裸 git 存储库放在
/var/www/html/test_repo
我在本地计算机上设置了我的 git 遥控器,如下所示:
git remote add test http://ServerIp/test_repo
但它给了我这个错误:
fatal: repository 'http://ServerIp/test_repo/' not found
您的 NGiNX 需要调用 /usr/lib/git-core/git-http-backend
以便 git 正确响应 clone/pull 命令。
例如 this answer:最好在 URL 路径中设置一个文件夹来跟踪 git 回购。
listen 80;
server_name myhostname;
access_log /var/log/nginx/git.access.log;
error_log /var/log/nginx/git.error.log;
gzip off;
location ~ /git(/.*) {
...
}
因此 git 回购协议的 URL 将是 http://ServerIp/git/test_repo,即使 fastcgi_param GIT_PROJECT_ROOT
参数将是 /var/www/html