如何防止删除纯 GIT 中的远程分支

How can I prevent deletion of remote branches in pure GIT

问题在 PURE GIT 而不是 GitHub、GitBucket、GitLab 等。

有没有办法使用钩子或其他任何东西,让我可以捕捉到有人试图删除远程分支的命令?

类似于命令"push --delete origin branchName"

预推或更新挂钩,不知道是否执行了"delete"。

非常奇怪的是,不小心或不理解某人甚至可以非常简单地删除像 "master" 这样的主要分支。一切都可以恢复是对的,但为什么这么麻烦?我无法将其标记为受保护或至少可以检查它是否正在完成的一些挂钩?

我们只使用 GIT 和 GitExtentions,简单的 http,我们不会切换到其他工具。

谢谢, 以利.

配置receive.denyDeletes可用于此:

$ git config receive.denyDeletes true

参见this reference at the very bottom

This denies any deletion of branches or tags – no user can do it. To remove remote branches, you must remove the ref files from the server manually.

或来自git config reference

If set to true, git-receive-pack will deny a ref update that deletes the ref. Use this to prevent such a ref deletion via a push.

这将在裸存储库上设置,或者 --system 全局设置在该系统上处理的所有存储库。