Checking a git client is clean

I use Git for many things, and I have written several utilities that wrap git commands (e.g. pushing changes to the theme for my wife’s website from the dev site to the production site). A common requirement is that the local copy is clean: no uncommitted changes, and no unpushed commits. I had been checking for uncommitted changes by testing if git status produces any output, but in most cases I wasn’t checking for unpushed commits. I decided to remove the duplication and improve the implementation by writing a git subcommand: git-check-local-copy-is-clean, invoked as git check-local-copy-is-clean. You can optionally ignore unpushed commits by using --ignore-unpushed-commits if you just care about uncommitted changes.