Use this command in your Terminal to determine if the directory you are currently in is a Git repository or not:
git rev-parse --is-inside-work-tree
The shell prints
true if you are in a git repository’s working tree. It prints
false if you are inside the ‘.git’ tree but not the working directory, and it prints a fatal error if it’s neither (not connected to any git repo).
Both ‘true’ and ‘false’ are printed on STDOUT with an exit status of 0, the fatal error is printed on STDERR with an exit status of 128.