为什么我的 Git 预提交挂钩没有在克隆存储库中触发?
我刚刚编写了一个小的预提交挂钩来执行我的自定义操作。我的中央存储库位于 Solaris 服务器上并启用了 HTTP。
/apps/opt/git/myrepo.git
我编辑了预提交挂钩并进行了如下修改:
#!/bin/sh -x
if [ $LOGNAME -ne bala ]; then
echo "You are not allowed"
exit 1;
fi
如果我克隆此存储库并使用其他用户执行提交操作,它不会给出任何消息,并会提交它。 为什么我的提交没有调用 pre-commit
挂钩?
我还可以在 .git/hooks
目录下的克隆存储库中看到,“pre-commit
”挂钩不存在,我只能看到默认模板。
有人可以帮忙吗?
I just wrote small pre-commit hook to perform my custom action. My central repository is on a Solaris server and HTTP enabled.
/apps/opt/git/myrepo.git
I edited pre-commit hook and modified as below:
#!/bin/sh -x
if [ $LOGNAME -ne bala ]; then
echo "You are not allowed"
exit 1;
fi
If I clone this repository and perform the commit action using other user, it doesn't give any message, and commits it.
Why is my commit not invoking the pre-commit
hook?
Also I could see in my cloned repo under .git/hooks
directory, the "pre-commit
" hook is not there, I can see only the default templates.
Can anyone help here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里的答案有几个要素:
预提交
(就像您所做的那样)。确保它是可执行的。预接收
Few elements of an answer here:
pre-commit
(like you did) on the local repo. Make sure it is executable.pre-receive
on the server side