Skip to content

Instantly share code, notes, and snippets.

@stalinkay
Forked from davidpdrsn/pre-push
Created March 7, 2022 16:14
Show Gist options
  • Save stalinkay/f604a5c9103826694107c74b5be26e2d to your computer and use it in GitHub Desktop.
Save stalinkay/f604a5c9103826694107c74b5be26e2d to your computer and use it in GitHub Desktop.
Git pre-push hook that prevents you from pushing commits with "WIP" in the message
#!/bin/sh
# Prevent you from pushing commits that have "WIP" in the message
branch=`git branch 2>/dev/null | grep '^*' | colrm 1 2`
git log $branch ^origin/$branch --pretty="format:%h %s" | grep "WIP"
if [[ $? -eq 0 ]]; then
echo "Found commits with WIP messages"
exit 1
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment