- Update my to-do list
b2cad55main☁ GitHubyou are here - More ideas
76fefe3 - Big title
7a63fb7big-title - Dark mode
31d2355dark-mode - Add a to-do list
f02c54d - Add my ideas
adc97b5 - My About Me page
8fa9095
Windows PowerShell (practice mode: nothing here touches your real computer)
Lesson 57: Secrets stay home
Level 7, Save Points: Git and GitHub. Keep keys and passwords out of Git with .gitignore. The new word: .gitignore. It follows lesson 56, GitHub and git push. Next comes lesson 58, Practice: save point drills.
What the lesson explains
Secrets stay home. Some files must never go online.
A key is a secret. An API key is like a house key. These ones are pretend. Real keys and passwords never go in a project, and never online. secrets.txt a key; .gitignore the list; Git skips them.
What you do first
Write the list. In the practice terminal, type echo secrets.txt > .gitignore at the prompt PS C:\Users\you\Documents\my-site>; the prompt then reads PS C:\Users\you\Documents\my-site>. It makes .gitignore.
The files on the practice computer
This lesson works in one folder. At the start, Documents\my-site holds images\, ideas.txt, index.html, style.css, todo.txt.
Along the way you find a note, secrets.txt, in Documents\my-site, save keys.env in Documents\my-site, type echo secrets.txt > .gitignore, type git add .gitignore, type git commit -m "Keep secrets home", type git add secrets.txt, type echo "*.env" >> .gitignore and type git commit -m "Ignore env files". Lesson 58 opens with the files just as you leave them.
What you practise
Try it, "Write the list": In the practice terminal, type echo secrets.txt > .gitignore at the prompt PS C:\Users\you\Documents\my-site>; the prompt then reads PS C:\Users\you\Documents\my-site>. It makes .gitignore. Then: In the practice terminal, type git status at the prompt PS C:\Users\you\Documents\my-site> and the computer answers: On branch main / Your branch is up to date with 'origin/main'. / Untracked files: / (use "git add <file>..." to include in what will be committed) / .gitignore / keys.env / nothing added to commit but untracked files present (use "git add" to track).
Try it, "Save the list": In the practice terminal, type git add .gitignore at the prompt PS C:\Users\you\Documents\my-site>; the prompt then reads PS C:\Users\you\Documents\my-site>. Then: In the practice terminal, type git commit -m "Keep secrets home" at the prompt PS C:\Users\you\Documents\my-site> and the computer answers: [main 0f599fd] Keep secrets home / 1 file changed / create mode 100644 .gitignore.
Fix it, "Caught in time": In the practice terminal, type git add secrets.txt at the prompt PS C:\Users\you\Documents\my-site> and the computer answers: The following paths are ignored by one of your .gitignore files: / secrets.txt / hint: Use -f if you really want to add them. / hint: (Ignored files usually hold secrets. Leave them out!).
Secret Spotter, "Which one is secret?": Which file should never go to GitHub? The answer: "passwords.txt".
Challenge, "Every .env file": Keep keys.env home too, and save the list. Starting at PS C:\Users\you\Documents\my-site>, one way takes 3 commands: echo "*.env" >> .gitignore; git add .gitignore; git commit -m "Ignore env files" (par: 3).
What PlayBuddy and PlayType say
PlayBuddy: "Some files hold secrets, like keys. They never go online!"
PlayType: "Write their names in dot gitignore, and Git leaves them out."
Help in every lesson
Everything happens on a pretend computer in your browser, so nothing touches your real files. PlayBuddy and PlayType stand beside the board, cheer you on and say when it is your turn.
A green ring shows where to click the first time. After that you do it on your own, and if you slip twice the ring comes back.
Stars
The lesson has 7 things to do. Up to one slip in ten gives three stars, up to one in four gives two, and finishing always gives at least one. Stars and progress are saved in this browser only; there is no account.
About DayOneCode
DayOneCode is an independent learning site, not affiliated with or endorsed by Anthropic. Claude and Claude Code are trademarks of Anthropic.