Check if current directory is a Git repository

I am writing a series of scripts for Git management in zsh.

How do I check if the current directory is a Git repository? (When I’m not in a Git repo, I don’t want to execute a bunch of commands and get a bunch of fatal: Not a git repository responses).

14 Answers
14

Leave a Comment