Skip to content

Instantly share code, notes, and snippets.

@DjMojoRisin
Created August 31, 2011 18:42
Show Gist options
  • Save DjMojoRisin/1184331 to your computer and use it in GitHub Desktop.
Save DjMojoRisin/1184331 to your computer and use it in GitHub Desktop.
Checks if there are any uncommitted changes in the current git branch.
#!/bin/bash
# This tool checks if there are any uncommitted changes in the current git branch.
# If it finds any uncommited changes it exits with an error.
# We use it to prevent pushing dirty changes to production.
clean=$(git status | grep "nothing to commit (working directory clean)")
if [ -z "$clean" ]; then
echo There are uncommitted changes.
exit 1
else
echo Branch is clean.
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment