我剛剛發現git的鉤(預接收後接收)不能運行,而這樣做的git推git的/掛鉤/預接收工作通過HTTP,但是這些鉤子可以在通過SSH進行git-push時調用。
這是正確的嗎?
那麼我怎樣才能讓git/hooks /預接受工作,而我們使用HTTP作爲訪問協議?
/// ------------------------------------------ -------------------------------------------------- ----
/// @SERVER
///這是 - 接收後鉤代碼
hello.git $ cat hooks/post-receive
#!/bin/bash
while read oldrev newrev ref
do
if [[ $ref =~ .*/master$ ]];
then
echo "Master ref received. Deploying master branch to production..."
#git --work-tree=/var/www/html --git-dir=/home/demo/proj checkout -f
else
echo "Ref $ref successfully received. Doing nothing: only the master branch may be deployed on this server."
fi
done
/// ---------------- -------------------------------------------------- ------------------------------
/// @ CLIENT
///這裏git/hooks/post-receive在通過SSH進行git推送時工作。
$ git push
[email protected]'s password:
Counting objects: 5, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (5/5), 390 bytes | 390.00 KiB/s, done.
Total 5 (delta 1), reused 0 (delta 0)
remote: Master ref received. Deploying master branch to production...
To hostxxx.net:/var/www/html/repo/hello.git
a308dbc..82184b8 master -> master
你用什麼服務器來推送HTTP? – phd
我們爲位於互聯網上的業務設置了一臺服務器,並且由於代理服務器的安全限制,我們必須使用HTTP/HTTPS協議而不是SSH。 那麼請給我任何建議? – zhengfish
是的,但是服務器究竟是什麼?簡單的HTTP服務器肯定不會運行服務器端的鉤子,你需要配置[git-http-backend](https://www.kernel.org/pub/software/scm/git/docs/git-http-backend。 HTML)。 – phd