BM: Baca dalam Bahasa Melayu
World 1: Save Points
Ignore files
You will learn: how to tell Git which files to never save.
The problem
Your folder fills up with junk: logs, downloads, even .env with your passwords. One careless git add . grabs it all.
Watch
A .gitignore file lists names Git should skip. One line, *.log, and both log files vanish from git status.
Watch
Each line is a pattern. A name ending in / means a folder. * means “anything”. > writes a new file, >> adds a line.
Try it
Should Git ignore it, or keep it? Sort each file.
Drag a card into a box. Or tap the card, then tap the box.
Try it
Hide the log files from Git. Then put .gitignore in the box.
- Empty
- 3 save points
- Add purple style
- Add home page
- Add README
Hint
Typeecho "*.log" > .gitignore. Then git add .gitignore.Check
You committed debug.log last week. Today you add *.log to .gitignore. What happens to debug.log?
Pick one answer.
You did it!
You can now keep junk and secrets out of your commits.
Go deeper (optional)
Commit your .gitignore, so your whole team uses it. A line starting with ! brings a file back, like !keep.log. git add . skips ignored files without a word.
Bahasa Melayu
Folder anda penuh sampah: log, muat turun, malah .env berisi kata laluan. Satu git add . yang cuai akan ambil semuanya.
Fail .gitignore (senarai benda untuk diabaikan) beritahu Git apa yang perlu dilangkau. Satu baris, *.log, dan kedua-dua fail log hilang dari git status.
Setiap baris ialah satu corak (pattern). Nama yang berakhir dengan / maksudnya folder. * maksudnya “apa-apa sahaja”. > tulis fail baru, >> tambah satu baris.
Patutkah Git abaikan, atau simpan? Susun setiap fail.
Sorokkan fail log daripada Git. Kemudian masukkan .gitignore ke dalam kotak.
echo "*.log" > .gitignore. Kemudian git add .gitignore.Minggu lepas, debug.log dah masuk dalam commit (titik simpan). Hari ini anda tambah *.log dalam .gitignore. Apa jadi pada debug.log?
Kini anda boleh jauhkan sampah dan rahsia daripada commit anda.
You finished this before. Practice is always welcome!
Official docs: gitignore
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?