linux - Git hooks 没有被推送到裸存储库

标签 linux git githooks git-commit

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

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

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

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 命令返回

commit 3403657fc4d08f406416711255cf04390a2df070 (HEAD -> master)
Author: “Malek <“<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5934203c34383035193e34383035773a3634" rel="noreferrer noopener nofollow">[email protected]</a>”>
Date:   Sat Oct 26 18:06:06 2019 -0400

    Write Makefile and hooks

commit 484c283a9faf0afed14328c9b71e635338c86187 (production)
Author: “Malek <“<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="acc1d5c9c1cdc5c0eccbc1cdc5c082cfc3c1" rel="noreferrer noopener nofollow">[email protected]</a>”>
Date:   Tue Oct 22 00:17:11 2019 -0400

    Master branch creation

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

最佳答案

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

接收后 Hook 是 server-side hook ,必须在远程存储库上手动安装/复制(即使该远程存储库位于同一台计算机上)。

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..

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

因此需要手动复制接收后 Hook (而不是预提交 Hook ,它无论如何都无法在裸存储库中工作)。

关于linux - Git hooks 没有被推送到裸存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58575177/

相关文章:

用于检测推送的 Git 钩子(Hook) --mirror

Windows 上的 Git : how to get pre-receive hook to run on the server using a file share

linux - 用于将文件从服务器传输到本地计算机的 Ksh 脚本

linux -/etc/ssh.cache 对 docker-sshd 意味着什么?

git - git push 如何处理积压的工作

python - 无法找到 Tesseract 的 tessdata

git - pytest 仅在推送时使用预提交 Hook 进行测试,而不是在提交时进行测试

linux - 用于 Fedora 的 Gcc-multilib

php - MySQL 错误,设置第一个数据库(phpmyadmin,linux 服务器)

Git 只克隆 .git 文件夹。不是所有文件