Check for git changes with bash

Check for git changes with bash

When running a deployment, I want to make sure, that all changes have been committed to git before it's executed. There is a special flag --porcelain for the git status command which does exactly this check.

Wrap this in an if command and you're good to go:

if [[ `git status --porcelain` ]]; then
  echo "There are files not committed yet"
  exit
fi