BM: Baca dalam Bahasa Melayu
World 2: Undo Magic
Which undo?
You will learn: how to pick restore, reset or revert for each mistake.
The problem
restore, reset, revert. Three undo words that sound alike. Pick the wrong one, and you might lose work.
Watch
Mistake not committed yet? Use restore: Put a file back to a saved version.. It fixes files in your folder or in the box.
Watch
Commit only on your laptop? Use reset: Move your branch back to an older commit.. It moves your branch back, as if the commit never happened.
Watch
Commit already shared? Use revert: Make a new commit that undoes an old one.. It adds a new commit that undoes the bad one.
Try it
Sort each mistake into the right undo.
Drag a card into a box. Or tap the card, then tap the box.
Hint
Ask: is it committed? Is it shared?Check
Which one can lose work for good?
Pick one answer.
You did it!
You can now pick the right undo for any mistake.
Go deeper (optional)
A quick map. Pick by where the mistake lives.
Not committed → git restore <file>
In the box → git restore --staged <file>
Last commit, typo → git commit --amend
Only on my laptop → git reset HEAD~1
Already shared → git revert <commit>Bahasa Melayu
restore, reset, revert. Tiga perkataan undur yang bunyinya hampir sama. Salah pilih, kerja anda mungkin hilang.
Kesilapan belum masuk commit (titik simpan)? Guna restore (pulihkan). Ia baiki fail dalam folder atau dalam kotak.
Commit hanya dalam laptop anda? Guna reset (undur). Ia undurkan branch (jalan cerita), seolah-olah commit itu tak pernah wujud.
Commit dah dikongsi? Guna revert (batalkan). Ia tambah commit baru yang batalkan commit yang teruk.
Susun setiap kesilapan ke dalam cara undur yang betul.
Yang mana boleh buat kerja hilang terus?
Kini anda boleh pilih cara undur yang betul untuk apa jua kesilapan.
You finished this before. Practice is always welcome!
Official docs: git restore · git reset · git revert
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?