Skip to content

Instantly share code, notes, and snippets.

@Genki-S
Created January 25, 2014 20:37
Show Gist options
  • Save Genki-S/8623216 to your computer and use it in GitHub Desktop.
Save Genki-S/8623216 to your computer and use it in GitHub Desktop.
#!/bin/sh
# See file status life cycle: http://git-scm.com/book/en/Git-Basics-Recording-Changes-to-the-Repository
untracked=$(git status --porcelain 2>/dev/null | grep "^??")
modified=$(git status --porcelain 2>/dev/null | grep "^ M")
staged=$(git status --porcelain 2>/dev/null | grep "^M")
if [ -n "$untracked" -o -n "$modified" -o -n "$staged" ]; then
echo "Working tree not clean." 1>&2
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment