docs: def _git(*command_parts, **kwargs):
      """ Convenience function for running git commands. Automatically deals with exceptions and unicode. """
      # Special arguments passed to sh: http://amoffat.github.io/sh/special_arguments.html
      git_kwargs = {'_tty_out': False}
      git_kwargs.update(kwargs)
      try:
          result = sh.git(*command_parts, **git_kwargs)  # pylint: disable=unexpected-keyword-arg
          # If we reach this point and the result has an exit_code that is larger than 0, this means that we didn't
          # get an exception (which is the default sh behavior for non-zero exit codes) and so the user is expecting
          # a non-zero exit code -> just return the entire result
          if hasattr(result, 'exit_code') and result.exit_code > 0:
              return result
          return ustr(result)
      except CommandNotFound:
          raise GitNotInstalledError()
      except ErrorReturnCode as e:  # Something went wrong while executing the git command
          error_msg = e.stderr.strip()
          if '_cwd' in git_kwargs and b"not a git repository" in error_msg.lower():
              error_msg = u"{0} is not a git repository.".format(git_kwargs['_cwd'])
          else:
              error_msg = u"An error occurred while executing '{0}': {1}".format(e.full_cmd, error_msg)
          raise GitContextError(error_msg)