Skip to content

Instantly share code, notes, and snippets.

@mozillazg
Created May 1, 2016 04:14
Show Gist options
  • Save mozillazg/b26a74f716ed5e786fe186fe64b8360c to your computer and use it in GitHub Desktop.
Save mozillazg/b26a74f716ed5e786fe186fe64b8360c to your computer and use it in GitHub Desktop.

Revisions

  1. mozillazg created this gist May 1, 2016.
    9 changes: 9 additions & 0 deletions pre-commit
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    protect_branch() {
    protected_name=$1
    current_name=$(git symbolic-ref HEAD | sed -e "s/^refs\/heads\///")
    if [ "$current_name" = "$protected_name" ]; then
    echo "!!! OH NO! you are trying to change the **$protected_name** branch!!!"
    exit 1
    fi
    }
    protect_branch master