Skip to content

Instantly share code, notes, and snippets.

@codingmatty
Last active March 22, 2019 17:27
Show Gist options
  • Save codingmatty/c1677149321a021bc40e90dbba58c053 to your computer and use it in GitHub Desktop.
Save codingmatty/c1677149321a021bc40e90dbba58c053 to your computer and use it in GitHub Desktop.
Check to make sure you are on a clean master branch
#!/bin/bash
if [ -n "$(git status --porcelain)" ]; then
echo "Aborting! Branch is unclean.";
exit 1
elif [ "$(git rev-parse --abbrev-ref HEAD)" != "master" ]; then
echo "Aborting! Not on master branch.";
exit 1;
elif [ "$(g rev-list master...origin/master)" != "" ]; then
echo "Aborting! Master branch not in sync with origin.";
exit 1;
else
echo "No git changes found.";
exit 0;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment