![](https://www.rmrf2020.com/upload/Git-Logo-1788C.png)
Git Hook
Git Hook
在 Git 使用中我们可能会要求禁止在 master 上开发,为了防止有人失误在 master上进行开发,就需要限制手段
这个限制手段就是 Git Hook
#!/bin/sh
protected_branch='master'
current_branch=$(git rev-parse --symbolic --abbrev-ref HEAD)
if [ "$protected_branch" == "$current_branch" ]; then
echo ".git/hooks: Do not commit to $current_branch branch"
exit 1
fi