Git reset is sharp and dangerous when used without discipline. In code scanning workflows, it can erase critical context. That missing context can hide vulnerabilities, change blame trails, and introduce silent drift between what’s real and what’s tested.
Secrets-in-code scanning depends on honest history. Tools that scan commits work best against a full timeline. When a developer runs git reset --hard to an earlier commit, they rewrite that timeline. Sensitive tokens once caught in a now-removed commit may no longer trigger alerts. Leaks disappear from the scanner’s view but remain in clones, forks, or cached build artifacts.
Avoid blind resets. If removal of commits is required to purge secrets, use git revert instead. Revert preserves the commit history, keeping the scanner’s detection intact. Combine this with commits scanning from the root, not from shallow clones. This ensures detection across all branches, including stale or orphaned ones.