Git 挂钩禁止在顶层创建目录
有什么更好的方法可以防止用户在推送或直接创建文件时停止创建顶级目录?
Any better way to prevent stop top level directory creation by users may be while on push or direct file creation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
此答案补充了 VonC 答案。
由于每个开发人员都应该有他/她自己的克隆(他/她自己的工作存储库),因此您实际上可以强加的唯一控制1是在推送发布存储库期间(或在拉取他们的存储库期间允许或禁止)变化)。这可以使用
update
或pre-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
orpre-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.您可以尝试 客户端挂钩,例如
请参阅此高级预提交挂钩示例看看在检查索引内容方面可以做什么。
You can try a client-side hook, like a
See this example of advance pre-commit hook to see what it is possible to do in term of checking the index content.
如果您确实希望对主存储库中的内容进行一定程度的控制,请不要让其他人推送它。相反,让经理从其他用户那里拉取并检查他们的更改以确保他们没有违反策略。
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.