Skip to content

Instantly share code, notes, and snippets.

@sergiandreplace
Created March 21, 2018 11:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sergiandreplace/9591c8f307c4bd25bc795c5359eb6bf3 to your computer and use it in GitHub Desktop.
Save sergiandreplace/9591c8f307c4bd25bc795c5359eb6bf3 to your computer and use it in GitHub Desktop.
Pre-commit script for git. To save without extension
#!/bin/sh
local_branch=$(git rev-parse --abbrev-ref HEAD)
if [[ ! "$local_branch" == feature* ]]
then
echo 'Failed to push. Branch name should start by feature/'
exit 1
fi
if [ "${#local_branch}" -ge 38 ]
then
echo 'Failed to push. Branch name could not be longer than 30 characters'
exit 1
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment