Skip to content

Instantly share code, notes, and snippets.

@eladg
Created August 27, 2021 23:48
Show Gist options
  • Save eladg/6386ae16aa96471c4283e253811c72ad to your computer and use it in GitHub Desktop.
Save eladg/6386ae16aa96471c4283e253811c72ad to your computer and use it in GitHub Desktop.
prevent commit on master/dev/prod branches
#!/bin/sh
branch="$(git rev-parse --abbrev-ref HEAD)"
if [ "$branch" = "master" ] || [ "$branch" = "dev" ] || [ "$branch" = "prod" ]; then
echo "You can't commit directly to $branch branch"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment