We need to write a client-side Git hook to detect a new branch creation from master. Whenever a new branch is created, a folder needs to be deleted from the branch.
I am not sure which hook is the best place to do this check or how to identify if the branch has just been created.
A client hook is tricky, as:
A server hook is easier (update hook), since it receives a zero sha for new refs.
That same hook can list the content of a commit
git diff-tree --no-commit-id --name-only -r <SHA1>
# or
git ls-tree -d --name-only -r <SHA1>
If a specific folder is still there, it can reject the push with an helpful message.
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