git hooks
2026-02-25To activate pre-push, rename .git/hooks/pre-push.sample to .git/hooks/pre-push
Example script:
branch_name=$(git symbolic-ref HEAD 2>/dev/null)
echo "$branch_name"
if [ "$branch_name" != "refs/heads/min-branch" ]; then
echo "You can't push this branch." # also prevents git push --force-with-lease
exit 1
fi
exit 0
should work given that this command:
git symbolic-ref HEAD 2>/dev/null
gives: refs/heads/min-branch
and:
git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3
gives min-branch