Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,20 @@ if [ -n "$FILES" ]; then
fi
fi


# Get the current branch name
current_branch=$(git rev-parse --abbrev-ref HEAD)

# Specify the branch to protect
protected_branch="master"

# Check if the current branch is the protected branch
if [ "$current_branch" = "$protected_branch" ]; then
echo "Error: Direct commits to '$protected_branch' branch are not allowed."
echo "Please switch to a different branch or create a new one."
exit 1 # Exit with a non-zero status to abort the commit
fi


# Normal exit
exit 0