This target will exit a Makefile if the working directory is not clean. Great for making sure you’ve commited changes before doing a production build/deployment.
Makefile
git-status:
@status=$$(git status --porcelain); \
if [ ! -z "$${status}" ]; \
then \
echo "Error - working directory is dirty. Commit those changes!"; \
exit 1; \
fi