BM: Baca dalam Bahasa Melayu
World 2: Undo Magic
Clean up junk files
You will learn: how to preview and delete untracked junk files.
The problem
Your diary folder is full of junk test files. Deleting them one by one is slow and boring.
Watch
git clean -f deletes untracked: A new file Git is not watching yet. files: new files Git never saved. This is called clean: Delete untracked junk files.. Tracked files stay safe.
Watch
⚠️ Danger: clean deletes for good. There is no bin and no undo. So always preview first with git clean -n.
Predict
You run git clean -n in this folder. Which files does it list?
index.html tracked
debug.log ignored (*.log)
test.html untracked
index-copy.html untracked
tmp/scribble.txt untracked, in a folderPick one answer.
Check
-n only shows, it deletes nothing. Add -d to include folders. debug.log never shows up, because it is ignored.
Try it
Preview first. Then delete the junk files and the tmp folder.
- Empty
- 4 save points
- Ignore log files
- Add style
- Add day 1 page
Hint
Preview withgit clean -n -d. Then delete with git clean -f -d.You did it!
You can now clean up junk files. Preview first, always!
Go deeper (optional)
Plain git clean refuses to delete anything without -f. That is Git being careful. -x deletes ignored files too, like .env or log files. Be very careful with it. This practice terminal blocks -x. git clean -i asks about each file.
Bahasa Melayu
Folder diari anda penuh dengan fail ujian yang tak berguna. Padam satu-satu? Lambat dan membosankan.
git clean -f padam fail untracked (tak dijejak): fail baru yang Git tak pernah simpan. Ini dipanggil clean (bersihkan). Fail yang dijejak kekal selamat.
⚠️ Bahaya: clean padam terus. Tiada tong sampah dan tiada undo. Jadi, sentiasa pratonton dulu dengan git clean -n.
Anda jalankan git clean -n dalam folder ini. Fail mana yang disenaraikan?
index.html dijejak
debug.log diabaikan (*.log)
test.html tak dijejak
index-copy.html tak dijejak
tmp/scribble.txt tak dijejak, dalam folder
-n cuma tunjuk, tiada apa dipadam. Tambah -d untuk masukkan folder. debug.log tak pernah muncul, sebab ia diabaikan.
Pratonton dulu. Kemudian padam fail sampah dan folder tmp.
git clean -n -d. Kemudian padam dengan git clean -f -d.Kini anda boleh bersihkan fail sampah. Pratonton dulu, setiap kali!
You finished this before. Practice is always welcome!
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?