Scan for known secrets in your source code before you check in
Pattern detection - use grep to find words like "password". git-secrets does this as well as pylint.
High entropy detection - detect-secrets does this.
Search for known secrets - Some secrets are found in conventional locations, such as AWS keys. They are typically key value pairs. As far as I known, this is a novel approach as of July 2018. So I wrote one.
All three approaches have different failure profiles.