BM: Baca dalam Bahasa Melayu
World 1: Save Points
Remove and rename
You will learn: how to delete, untrack and rename files the Git way.
The problem
Your diary needs a clean-up. An old notes file. A page with a clumsy name. A log you saved by mistake. How do you tell Git?
Watch
git rm deletes a file and puts the deletion in the box. Your next commit saves it as gone.
Try it
Delete old-notes.txt the Git way.
- Empty
- Empty
- 3 save points
- Ignore log files
- Add diary pages
- Add README
Hint
Typegit rm old-notes.txt.Predict
You run git rm --cached debug.log. Is debug.log still in your folder?
Pick one answer.
Watch
git rm --cached means: stop tracking, but keep the file. Perfect for things you saved by mistake. Your .gitignore keeps it hidden after.
Watch
git mv renames a file and tells Git in one step. The R in status means renamed.
Try it
Rename aboutme.html to about.html. Then commit it.
- Empty
- Empty
- 3 save points
- Ignore log files
- Add diary pages
- Add README
Hint
git mv aboutme.html about.html, then git commit -m "Rename about page".You did it!
You can now delete, untrack and rename files without confusing Git.
Go deeper (optional)
Deleted or renamed a file without Git? No problem. Run git add -A. Git puts the deletion in the box. It usually spots a rename too. For a whole folder, use git rm -r and the folder name.
Bahasa Melayu
Diari anda perlu dikemas. Ada fail nota lama. Ada laman dengan nama janggal. Ada log yang tersimpan secara tak sengaja. Macam mana nak beritahu Git?
git rm padam fail dan masukkan pemadaman itu ke dalam kotak. Commit (titik simpan) seterusnya akan simpan fail itu sebagai dah tiada.
Padam old-notes.txt cara Git.
git rm old-notes.txt.Anda jalankan git rm --cached debug.log. Adakah debug.log masih dalam folder anda?
git rm --cached maksudnya: berhenti jejak, tapi simpan fail itu. Sesuai untuk benda yang tersimpan secara tak sengaja. .gitignore anda akan terus sorokkannya.
git mv tukar nama fail dan beritahu Git dalam satu langkah. Huruf R dalam status maksudnya renamed (ditukar nama).
Tukar nama aboutme.html jadi about.html. Kemudian commit.
git mv aboutme.html about.html, kemudian git commit -m "Rename about page".Kini anda boleh padam, berhenti jejak dan tukar nama fail cara Git.
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?