Git 服务器在推送合并提交时发出警告

发布于 2024-12-13 20:49:39 字数 160 浏览 1 评论 0原文

我们有一个 git 工作流程,主要基于本地主题分支的变基,以实现尽可能线性的提交树。然而有时需要合并,我们确实允许这样做。

如何设置 git 服务器来警告用户,当他们尝试将合并提交推送到服务器时? 我只想警告用户并要求他们确认这就是他们想要的真的很想做。

We have a git workflow which is mostly based on rebasing local topic branches, as to achieve as linear a commit tree as possible. However sometimes it is necessary to merge and we do allow that.

How can I set up my git server to warn the user, when they try to push a merge commit to the server? I would like to just warn the user and ask them to confirm that this is what they really want to do.

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

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

发布评论

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

评论(1

时光瘦了 2024-12-20 20:49:39

如果您使用的是标准版本的 git,我认为您无法按照您的问题所建议的方式以交互方式执行此操作。然而,一种可能的替代方案是在服务器上设置一个 pre-receive 挂钩,该挂钩将拒绝任何不包含特定字符串的合并提交,例如 Merge Reviewedpre-receive 钩子在接收会引入此类合并提交的推送时输出的错误也建议使用历史重写(git commit --amendgit rebase) 在推送之前将该字符串或 rebase 添加到线性历史记录中。

I don't think you can do this interactively in the way that your question suggests if you are using standard versions of git. One possible alternative, however, is to have a pre-receive hook on the server that will refuse any merge commits that don't contain a particular string, say Merge Reviewed. The error output by the pre-receive hook on receiving a push that would introduce such a merge commit would also suggest using history rewriting (git commit --amend or git rebase) to add that string or rebase into linear history before pushing.

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