The command looked harmless, but the repo was gone. One git checkout and an unchecked branch name had wiped hours of work.
Git checkout security reviews are not optional when the stakes are your codebase. Attackers know that a poisoned branch name, submodule, or crafted path can turn a routine command into a supply chain breach. The checkout process touches your filesystem, moves HEAD, and pulls in history you might not have vetted. Every one of those steps is a potential attack surface.
A secure Git checkout is more than just running --force and hoping for the best. You need a process. Review all branch and tag names for unsafe characters. Block names that reference remote-tracking branches you don't trust. Enforce signed commits and tags before checkout. Inspect submodule URLs for malicious rewrites. Turn on sparse checkout rules to limit file exposure.