Git 挂钩禁止在顶层创建目录

发布于 2024-09-11 05:26:18 字数 41 浏览 2 评论 0原文

有什么更好的方法可以防止用户在推送或直接创建文件时停止创建顶级目录?

Any better way to prevent stop top level directory creation by users may be while on push or direct file creation?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

秉烛思 2024-09-18 05:26:18

此答案补充了 VonC 答案


由于每个开发人员都应该有他/她自己的克隆(他/她自己的工作存储库),因此您实际上可以强加的唯一控制1是在推送发布存储库期间(或在拉取他们的存储库期间允许或禁止)变化)。这可以使用 updatepre-receive 钩子

1)可以使用“git commit --no-verify”绕过预提交挂钩

我不知道是否有任何现成的解决方案支持您想要施加的约束,但我认为 update-paranoid 示例钩子(来自 git 源代码中的 contrib/hooks )和 gitolite (管理访问权限的工具git 存储库)可以扩展以支持它;两者都可以进行基于路径/基于差异的约束,例如仅允许更改给定的配置子目录。

This answer supplements VonC answer.


As each developer should have his/her own clone (his/her own working repository), the only control you can realistically impose1 is on allowing or disallowing during push to publish repository (or during you pulling their changes). This can be done using update or pre-receive hook.

1) The pre-commit hook can be bypassed with "git commit --no-verify"

I don't know if any ready solution support constraint you want to impose, but I think that both update-paranoid example hook (from contrib/hooks in git sources), and gitolite (the tool to manage access to git repositories) can be extended to support it; both can do path based / diff based constraints, for example allow changes only to given configured subdirectory.

因为看清所以看轻 2024-09-18 05:26:18

您可以尝试 客户端挂钩,例如

在您输入提交消息之前,pre-commit 挂钩会首先运行。
它用于检查即将提交的快照,查看您是否忘记了某些内容,确保测试运行,或者检查代码中需要检查的任何内容。从此挂钩退出非零会中止提交,尽管您可以使用 git commit --no-verify 绕过它。

请参阅此高级预提交挂钩示例看看在检查索引内容方面可以做什么。

You can try a client-side hook, like a

The pre-commit hook is run first, before you even type in a commit message.
It’s used to inspect the snapshot that’s about to be committed, to see if you’ve forgotten something, to make sure tests run, or to examine whatever you need to inspect in the code. Exiting non-zero from this hook aborts the commit, although you can bypass it with git commit --no-verify.

See this example of advance pre-commit hook to see what it is possible to do in term of checking the index content.

拍不死你 2024-09-18 05:26:18

如果您确实希望对主存储库中的内容进行一定程度的控制,请不要让其他人推送它。相反,让经理从其他用户那里拉取并检查他们的更改以确保他们没有违反策略。

If you really want that level of control over what goes into the master repository, don't let other people push to it. Instead, have the manager pull from other users and review their changes to make sure they haven't violated policies.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文