現在、pre-commitフックを使用して、マスターブランチへのコミットを禁止しています(他のブランチで作業し、変更をマージするように強制します)。これでは、新しく作成されたリポジトリで最初のコミットを実行できません。マスターが最初のコミットである場合に、マスターでのコミットを許可するチェックを追加したいと思います。
私はこれの複数のバージョンを運が悪かったので試しました...
if [[ `git shortlog | grep -E '^[ ]+\w+' | wc -l | tr -d ' '` == 0 -a `git symbolic-ref HEAD` == "refs/heads/master" ]]
then
echo "You cannot commit in master!"
echo "Stash your changes and apply them to another branch"
echo "git stash"
echo "git checkout branch"
echo "git stash apply"
exit 1
fi