BM: Baca dalam Bahasa Melayu
World 1: Save Points
The Box
You will learn: how to save only the files that are ready.
The problem
You changed 3 files. Only 1 is ready. How do you save just that one?
Watch
Git has a box. It is called the staging area. Ready changes go in the box.
Watch
git add index.html puts one file in the box.
Try it
Tap a file, then tap a box. Or drag it.
- Drop here
Drag only the ready file into the box.
Hint
Look for the green tick.Try it
- Empty
- 1 save point
- Add README
Now type the command yourself.
Hint
Typegit add index.html, then press Enter.Watch
A commit takes a photo of the box. Only what is inside gets saved.
Predict
You run git commit now. Which files are saved?
Pick one answer.
Check
In git status, green means “in the box”. Red means “not yet”.
You did it!
You can now save only what is ready.
Go deeper (optional)
git add -p saves only part of a file. git restore --staged takes a file out of the box.
Bahasa Melayu
Anda ubah 3 fail. Hanya 1 yang dah siap. Macam mana nak simpan yang itu sahaja?
Git ada satu kotak. Namanya kawasan staging. Perubahan yang siap masuk ke dalam kotak.
git add index.html masukkan satu fail ke dalam kotak.
Seret fail yang dah siap sahaja ke dalam kotak.
Sekarang taip arahan itu sendiri.
git add index.html, kemudian tekan Enter.Commit (titik simpan) ambil gambar isi kotak. Hanya yang di dalam akan disimpan.
Anda jalankan git commit sekarang. Fail mana yang disimpan?
Dalam git status, hijau maksudnya “dalam kotak”. Merah maksudnya “belum lagi”.
Kini anda boleh simpan hanya yang dah siap.
You finished this before. Practice is always welcome!
Official docs: git add · git restore · git status
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?