Skip to content

Instantly share code, notes, and snippets.

@Bogdaan
Created September 21, 2022 17:32
Show Gist options
  • Save Bogdaan/8b1a45a61b1d01f92fbdcfc4ab682a6d to your computer and use it in GitHub Desktop.
Save Bogdaan/8b1a45a61b1d01f92fbdcfc4ab682a6d to your computer and use it in GitHub Desktop.

Revisions

  1. Bogdaan created this gist Sep 21, 2022.
    21 changes: 21 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    #!/bin/bash
    protected_branch='master'
    current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')

    if [ $protected_branch = $current_branch ]
    then

    echo -en "\033[31mYou're about to push master, is that what you intended? [y|n] \033[0m"
    echo -en "\033[1m"
    read -n 1 -r < /dev/tty
    echo -en "\033[0m"

    echo
    if echo $REPLY | grep -E '^[Yy]$' > /dev/null
    then
    exit 0 # push will execute
    fi
    exit 1 # push will not execute
    else
    exit 0 # push will execute
    fi