ExternalProject: Explicitly run Git commands on intended directory

Add `--git-dir=.git` to cause git commands to fail instantly if the
`.git` folder has gone missing.

Fixes: #24007
1 file changed