git with --git-dir= results in 'not a git repository'
问题 I have a script in one of my iOS apps that should get the git revision hash and put it in the version number. In this script I run git --git-dir="$PROJECT_DIR" show -s --pretty=format:%h for that. However, I get the message that the directory isn't a git repository. If I echo the PROJECT_DIR var and go to the terminal the following works: cd projectDirPath git show -s --pretty=format:%h What doesn't work is: git --git-dir=projectDirPath show -s --pretty=format:%h Am I missing something? The