Git 服务器在推送合并提交时发出警告
我们有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用的是标准版本的 git,我认为您无法按照您的问题所建议的方式以交互方式执行此操作。然而,一种可能的替代方案是在服务器上设置一个
pre-receive
挂钩,该挂钩将拒绝任何不包含特定字符串的合并提交,例如Merge Reviewed
。pre-receive
钩子在接收会引入此类合并提交的推送时输出的错误也建议使用历史重写(git commit --amend
或git 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, sayMerge Reviewed
. The error output by thepre-receive
hook on receiving a push that would introduce such a merge commit would also suggest using history rewriting (git commit --amend
orgit rebase
) to add that string or rebase into linear history before pushing.