use mixin to add 'is git repo' check for some commands

When those commands are used outside a git repo, 'Not a git repo!' will be
printed to stderr
Merge pull request #258 from spacewander/master

use mixin to add 'is git repo' check.