问题在 PURE GIT 而不是 GitHub、GitBucket、GitLab 等。
有没有办法用钩子(Hook)或其他任何东西,我可以捕捉到有人试图删除远程分支的命令?
类似于命令“push --delete origin branchName”
预推或更新 Hook ,不知道是否执行了“删除”。
非常奇怪的是,意外地或不了解某人甚至可以非常简单地删除像“master”这样的主要分支。一切都可以恢复是对的,但为什么这么麻烦?我无法将其标记为 protected 或至少可以检查它是否正在完成的一些 Hook ?
我们只使用带有 GitExtentions 的 GIT,使用简单的 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
全局设置在该系统上处理的所有存储库。
关于git - 如何防止删除纯 GIT 中的远程分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48381923/