New developers keep committing `.env`, IDE folders and OS junk files.
BeginnerScenarioSecrets, Signing and Security
Answer
Situation read → Good ignore rules prevent most accidents.
What I'd do →
- Maintain a project
.gitignoreusing a language template, with.env*except.env.example. - Keep personal junk in a global ignore:
git config --global core.excludesFile ~/.gitignore_global. - Check why a file is ignored:
git check-ignore -v path. - Add
.envscanning to pre-commit.
Why → Project rules cover project artifacts; global rules cover your editor and OS.
Interview tip → .gitignore never affects files that are already tracked.
More on Secrets, Signing and Security
A developer pushed an AWS access key to a public repo 10 minutes ago. What is your first move?BeginnerAfter rotating the leaked key, you must purge it from repository history. How?AdvancedA push is rejected: "GH013: Repository rule violations found ... Push cannot contain secrets". What do you do?IntermediateSecret scanning alerts have piled up, and many look like false positives or old test credentials.IntermediateYou must set up signed commits on your laptop. Which method do you pick?BeginnerYour GPG signing key expires next week. What is the correct way to handle it?Intermediate