禁止直接commit到master branch - jenhaoyang/backend_blog GitHub Wiki
- 到有git版控的專案資料夾
- 製作一個檔案.git/hooks/pre-commit 包含以下內容
#!/bin/sh
branch="$(git rev-parse --abbrev-ref HEAD)"
if [ "$branch" = "master" ]; then
echo "You can't commit directly to master branch"
exit 1
fi
3.讓檔案設為可執行
$ chmod +x .git/hooks/pre-commit