BM: Baca dalam Bahasa Melayu
World 2: Undo Magic
Reflog, your safety net
You will learn: how to find and bring back "lost" commits.
The problem
Oops. You typed git reset --hard HEAD~1. Your day 3 entry vanished. Panic?
Watch
No panic. Git keeps a diary of every place HEAD has been. This is the reflog: Git's diary of everywhere HEAD has been.. Your lost commit is still listed.
Try it
Find your lost commit in the reflog.
Tap the line with Add day 3 entry.
0 of 1 found
Hint
Look for the words “Add day 3 entry”.Watch
HEAD@{1} means “where HEAD was one move ago”. You can use that name in commands.
Try it
Bring the day 3 commit back.
Hint
Typegit reset --hard HEAD@{1}, then press Enter.Predict
What can the reflog bring back?
Pick one answer.
You did it!
You can now bring back “lost” commits with the reflog.
Go deeper (optional)
The reflog lives only on your computer. It is never pushed. Old lines expire, after 90 days by default. Lines for lost commits go after 30. You can also reset to a hash from the reflog list.
Bahasa Melayu
Alamak. Anda taip git reset --hard HEAD~1. Catatan day 3 anda lesap. Panik?
Jangan panik. Git simpan diari setiap tempat HEAD pernah pergi. Ini dipanggil reflog (diari HEAD). Commit (titik simpan) yang hilang masih tersenarai.
Cari commit anda yang hilang dalam reflog.
HEAD@{1} maksudnya “tempat HEAD berada satu langkah lalu”. Anda boleh guna nama itu dalam arahan.
Bawa balik commit day 3 itu.
git reset --hard HEAD@{1}, kemudian tekan Enter.Apa yang reflog boleh bawa balik?
Kini anda boleh bawa balik commit yang “hilang” dengan reflog.
You finished this before. Practice is always welcome!
Official docs: git reflog · git reset · Revision names (HEAD@{1})
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?