git: fix --HEAD builds to report proper version

For the GIT-VERSION-FILE scripts to work properly, it either
needs to have $GIT_DIR pointing to the '.git' directory or find
'.git' within the cwd.

Further, for `git describe` to work correctly, we can't use a
shallow clone (at least not one of depth 1), as it needs to find
a tag within recent history.

Closes #27227.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>