How to prevent committing secrets to a GitHub repository #175007
-
| Select Topic AreaQuestion BodyHi everyone, I’m working on a project with multiple collaborators, and sometimes we accidentally commit API keys or other secrets to the repository. I’d like to set up a way to prevent these commits before they happen. I’ve heard about tools like GitHub secret scanning and pre-commit hooks, but I’m not sure what the best approach is. What’s the simplest way to stop secrets from being pushed to the repo, ideally using GitHub’s built-in tools? Thanks! | 
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
| You can use GitHub’s built-in secret scanning to help with this. 
 For extra protection, you can also use a local pre-commit hook with a tool like pre-commit | 
Beta Was this translation helpful? Give feedback.
You can use GitHub’s built-in secret scanning to help with this.
For extra protection, you can also use a local pre-commit hook with a tool like pre-commit
or git-secrets. This stops secrets before they leave your machine.