Skip to content

Instantly share code, notes, and snippets.

@mjdominus
Created December 16, 2011 15:44
Show Gist options
  • Save mjdominus/1486532 to your computer and use it in GitHub Desktop.
Save mjdominus/1486532 to your computer and use it in GitHub Desktop.
is the working tree dirty?
# This is the function that git-rebase--interactive uses to determine if the
# working tree is clean, and to bail out if not
require_clean_work_tree () {
# test if working tree is dirty
git rev-parse --verify HEAD > /dev/null &&
git update-index --ignore-submodules --refresh &&
git diff-files --quiet --ignore-submodules &&
git diff-index --cached --quiet HEAD --ignore-submodules -- ||
die "Working tree is dirty"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment