doctor: ensure git --version actually matches.

Closes #23791.