git - 是否可以在本地强制执行签名提交?
问题描述
我的公司将 GitHub 用于我们的组织存储库,并通过强制签名提交来验证作者。
问题是可以克隆一个 repo,创建一个分支,提交多个提交,并创建一个 Pull Request,而无需任何签名的提交。直到尝试将该PR 合并到 PR 合并失败的受签名提交保护的分支develop
或main
任何受签名提交保护的分支。那时,我们必须用 a 清理它,rebase
这样就没有没有签名的提交。
有没有办法在回购的本地克隆上强制执行签名?如果没有签名,可以确保提交失败的预提交钩子之类的东西?一些东西,一旦设置,看起来像这样:
> git clone <my-company's-git-repo-with-signatures-required-on-main-branch>
> cd <my-company's-git-repo-with-signatures-required-on-main-branch>
> git switch main # Just to make it clear that I am on the protected branch
> touch my-new-file
> git add my-new-file
> git commit -m "Testing" # And this is for a user that does not have signing set up yet.
Git Error: Cannot commit without signature # Or whatever the error message would be
这可以防止任何形式的“回滚”通过rebase
或任何其他可能的方法。
解决方案
我认为这不可能强迫某人创建签名提交,或者类似的事情进行force signed commit
检查。
因为这是您公司的存储库,签名提交是必须的。你可能想制定一条规则:任何为此存储库做出贡献的人都应该进行签名提交。
仅供参考:您可以做的是将 git 别名设置normal commit
为signed commit
.
就像是:
s-commit = !sh -c 'git commit -S $*'
甚至总是对已签名的提交进行提交.. :-)
当然,任何贡献都应使用或遵守此规则。
推荐阅读
- java - 从 Firebase 存储下载 url 是“com.google.android.gms.tasks.zzu@441922b”,不显示
- linux - 用于使用 xargs 对另一个命令生成的搜索文本的一个命令的输出进行 grep 的一个衬垫
- javascript - 未在移动浏览器上检索会话存储
- android - 共享内存方法是否通过活页夹进行进程间通信?
- amazon-web-services - 如何为具有自控证书的 AWS S3 终端节点启用 TLS?
- javascript - 转换:translateY(-50%) 无法正常工作
- regex - 正则表达式在 emeditor 中查找并用 4 位日期替换 2 位日期
- python - 删除 MySQL 表中的一些行
- c# - 如何将交换机与服务链接
- html - 链接预取是否跨子域工作?