BM: Baca dalam Bahasa Melayu
World 11: Rescue Center
I pushed a password
You will learn: what to do first when a secret reaches GitHub.
The problem
You pushed. Then you spot it: .env holds your secret key. And it’s on GitHub now. Breathe. This happens to everyone. Here’s the safe way out.
Try it
What do you do first?
Pick one answer.
Hint
A leaked key must stop working before anything else.Watch
The key is rotated. Now clean up. git rm --cached .env tells Git to stop tracking the file. It stays on your computer.
Try it
Stop tracking .env. Add it to .gitignore. Commit and push.
- Empty
- Empty
- 4 save points
- Add weather widget
- Add style
- Add day 1 page
Hint
Typegit rm --cached .env, then echo ".env" >> .gitignore, then git add .gitignore. Then commit and push.Predict
Your newest commit has no .env. Is the key gone from GitHub?
Pick one answer.
Check
Good move, or needs work? Swipe each one.
Swipe right for good, left for needs work. Or use the buttons.
Rotate the key before anything else
You did it!
You can now handle a pushed secret: rotate first, then clean up.
Go deeper (optional)
Not pushed yet? Nobody saw it. Untrack and ignore .env, then run git commit --amend --no-edit. Pushed? Wiping the key from every old commit takes git filter-repo. World 8’s lesson “Leaked a key? Rotate first” shows how. GitHub’s push protection can block some secrets before they leave.
Bahasa Melayu
Anda dah push. Kemudian anda perasan: .env simpan kunci rahsia anda. Dan kini ia di GitHub. Tarik nafas. Ini berlaku pada semua orang. Ini cara selamat untuk keluar.
Apa yang anda buat dulu?
Kunci dah ditukar. Sekarang kemaskan. git rm --cached .env suruh Git berhenti jejak fail itu. Ia kekal dalam komputer anda.
Berhenti jejak .env. Tambah ke .gitignore. Commit (titik simpan) dan push.
git rm --cached .env, kemudian echo ".env" >> .gitignore, kemudian git add .gitignore. Lepas tu commit dan push.Commit terbaru anda tiada .env. Adakah kunci itu dah hilang dari GitHub?
Langkah bagus, atau perlu dibaiki? Leret setiap satu.
Kini anda boleh uruskan rahsia yang terpush: tukar kunci dulu, kemudian kemaskan.
You finished this before. Practice is always welcome!
Official docs: git rm · Removing sensitive data from a repository · About secret scanning
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?