我是git和git hook的新手。我不想使用sftp將文件上傳到我的服務器。我想用githook做。於是我創建了一個文件夾 /var/site_files/site.git
並運行git init --bare
命令。然後,我創建了以下文件。 var/site_files/site.git/hooks/post-receive
並添加以下行到它 #!/bin/bash git --work-tree=/var/www/my_site.com --git-dir=/var/site_files/site.git checkout -f
githook權限問題
我也有我的本地機器上添加了一個遠程(名爲production)。 當我使用git push production master
,我得到以下錯誤的所有文件:
remote: error: unable to unlink old '.env.example' (Permission denied) remote: error: unable to unlink old '.gitattributes' (Permission denied)
我需要爲我的/var/site_files/
文件夾設置哪些權限? 我現在的權限如下: drwxrwxr-x 3 myname myname 4096 Apr 19 15:05 site_files
我是否需要更改權限/var/www/my_site.com
文件夾?
Git鉤子以接收傳入數據的用戶身份運行。這取決於你使用的是哪個Git協議:例如'git push ssh://[email protected]/...'以'user'登錄,而'git push https:// ...'會無論HTTPS服務器如何,這取決於您的服務器。其餘細節與操作系統相關,並且可能比這更深入(例如,SELinux基本上意味着沒有人可以觸摸任何東西:-))。 – torek
我得到了我的答案。我必須更改我的文檔根文件夾的權限。文檔根是由根創建的,而使用git鉤子時,我試圖將更改推送爲另一個用戶。 只需要運行sudo chown -R'whoami':'id -gn' /var/www/my_site.com –
@PritamBohra您應該將其作爲回答,而不是評論。 – 1615903