BM: Baca dalam Bahasa Melayu
World 2: Undo Magic
Take it out of the box
You will learn: how to take a file out of the box without losing your work.
The problem
You typed git add . too fast. A half-done file jumped into the box. How do you get it out?
Watch
git restore --staged style.css takes the file out of the box. This is called unstaging.
Try it
Drag the half-done file back out of the box.
Tap a file, then tap a box. Or drag it.
- Drop here
Hint
Look for the “not ready” tag.Try it
Now type the command yourself.
- Empty
- 3 save points
- Add style
- Add day 1 page
- Add README
Hint
Typegit restore --staged style.css, then press Enter.Predict
You just unstaged style.css. Where are your edits now?
Pick one answer.
Check
Forgot the command? git status tells you. Look for the hint that says “to unstage”.
You did it!
You can now take a file out of the box, safely.
Go deeper (optional)
git reset style.css does the same thing. It is the older way. git restore --staged . empties the whole box.
Bahasa Melayu
Anda taip git add . terlalu cepat. Fail yang separuh siap pun masuk ke dalam kotak. Macam mana nak keluarkan?
git restore --staged style.css keluarkan fail itu dari kotak. Ini dipanggil unstage (keluarkan dari kotak).
Seret fail yang separuh siap keluar dari kotak.
Sekarang taip arahan itu sendiri.
git restore --staged style.css, kemudian tekan Enter.Anda baru unstage style.css. Di mana perubahan anda sekarang?
Lupa arahannya? git status akan beritahu. Cari petunjuk yang sebut “to unstage”.
Kini anda boleh keluarkan fail dari kotak dengan selamat.
You finished this before. Practice is always welcome!
Official docs: git restore · git status · git reset
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?