I have ready many articles about protecting remote branches...
I however would like to capture in a git hook the following LOCAL repo command:
git branch -d abranchthatshouldnotbedeleted
I would like to hook that command and analyze it against an branch list file of "protected branches" that I made and do a simple check to allow or deny the delete.
Certain branches of mine are now locked in a stated where they are managed now and must be protected.
Since GitHub doesn't allow pre-receive hook (only post-receive ones), I would recommend pushing to an intermediate local repo, protected by Gitolite (an authorization layer, through ssh or http access to your git repo).
Gitolite can help code all kind of access rules, including protecting a branch against deletion.
If the push is allowed, then a post-commit hook can push that automatically to GitHub.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With