git rev-parse --is-inside-work-tree 2>/dev/null >/dev/null

is_git_repo() {
  git rev-parse HEAD >/dev/null 2>&1
}

if [ -z "${is_git_repo}" ]; then
  printf '%s\n' "not in a git repo!"
  exit 1
fi

if ! git rev-parse HEAD >/dev/null 2>&1; then
  printf '%s\n' "fatal: not in a git repo! ¯\_(ツ)_/¯"
  exit 1
fi
