Move head-only checks to cmd/install

Fixes #30084.
Closes #30203.