Git 钩子没有被推送到裸仓库

Git hooks not getting pushed to bare repository

我在主机上有一个裸存储库,在我的笔记本电脑上有一个本地存储库。 我有 2 个挂钩:一个预提交挂钩和一个 post-接收挂钩。两者都在我的本地挂钩文件夹中:

malek@laptop:~/Desktop/portfolio-website/.git/hooks$ ls
post-receive  pre-commit

当然,我将我的本地存储库推送到远程存储库(我的本地预提交挂钩工作正常)但是我的挂钩没有在我的裸远程存储库上更新。

malek@laptop:~/Desktop/portfolio-website/.git/hooks$ git push -u origin --all
Branch 'master' set up to track remote branch 'master' from 'origin'.
Branch 'production' set up to track remote branch 'production' from 'origin'.
Everything up-to-date

如下图所示:

malek@localhost:~/portfolio-website/hooks$ ls
applypatch-msg.sample      pre-applypatch.sample      pre-rebase.sample
commit-msg.sample          pre-commit.sample          pre-receive.sample
fsmonitor-watchman.sample  prepare-commit-msg.sample  update.sample
post-update.sample         pre-push.sample

git log master命令returns

commit 3403657fc4d08f406416711255cf04390a2df070 (HEAD -> master)
Author: “Malek <“myemail@gmail.com”>
Date:   Sat Oct 26 18:06:06 2019 -0400

    Write Makefile and hooks

commit 484c283a9faf0afed14328c9b71e635338c86187 (production)
Author: “Malek <“myemail@gmail.com”>
Date:   Tue Oct 22 00:17:11 2019 -0400

    Master branch creation

如果提交成功发送,为什么我的挂钩没有在我的远程存储库上更新?

预提交挂钩是 client side hook,它将保留(与任何挂钩一样)在您的本地存储库中;

A post-receive hook 是一个 server-side hook,它必须在远程仓库上手动 installed/copied(即使远程仓库在同一台机器上)。

I have a soft symbolic link to my hooks folder in my project's directory so I would assume that those hooks would be updated on the bare repository as well..

由于挂钩不是推送内容的一部分 (for security reason),因此不会在远程存储库上复制该符号链接。

因此需要手动复制 post-receive 挂钩(不是预提交挂钩,它无论如何都不会在裸存储库中工作)。