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

标签 git hook atlassian-sourcetree git-extensions

问题在 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/

相关文章:

git - SourceTree git "clone from url"给我 fatal error

git - 每个 Visual Studio 版本都需要自己克隆的 git 存储库吗?

ruby-on-rails - 试图添加 .rvmrc 以忽略,它不起作用

git - 如何使用 git lfs 进行 rebase ?

python - 如何从运行时代码访问 PyInstaller Hook 文件命名空间中的变量?

git - 使用 Atlassian SourceTree,存储应用期间出错。不知道该怎么办

git - 致命的 : Unable to create temporary file '/home/username/git/myrepo.git/./objects/pack/tmp_pack_XXXXXX' : Permission denied

git - Bitbucket 全局钩子(Hook)或默认配置

javascript - 如何在 jQuery ui 对话框按钮单击中提供 Hook ?

git - 使用 Squash 时无法确定分支是否已 merge