Stage 2 · Lesson 3 of 9
Keeping secrets and junk out of Git
Everything you and push stays in the project's history, even if you delete the file later. So never commit passwords, API keys (secret codes that let your program use a service) or database . Automated bots scan public GitHub repositories for leaked keys within minutes.
Keep secrets in (settings your program reads when it starts) or in a .env file. List that file in .gitignore, the file that tells Git what never to track. Add build output, folders such as node_modules or venv, and editor files too.
If a key does leak, revoke it (cancel it) at the provider straight away. Deleting it in the next commit is not enough: the key is still in the history, and bots may already have a copy. cannot take it back once it is public. Set up .gitignore when you create a repository, not after the first accident.
A question to check yourself, an AI practice session and 2 cheat sheet entries come with the full roadmap. Unlock
Resources for this stage
Start with· follow one of these
- GitHub repoFreeGitHub Skills: Introduction to GitHub
GitHub · Beginner
Free hands-on exercise: branch, commit, open and merge a pull request in about an hour
- CourseFreeThe Missing Semester of Your CS Education
MIT · Beginner
MIT lectures on the tools degrees skip; the shell and version control lectures are enough here
Practise
Keep handy
Also worth your time
How to choose, structure and present projects so a reviewer sees your best work first