BM: Baca dalam Bahasa Melayu
World 11: Rescue Center
I forgot a file
You will learn: how to add a forgotten file to your last commit.
The problem
You committed your day 2 page. But its style file is still on your desk! This happens to everyone. Here’s the safe way out.
Try it
You haven’t pushed yet. What’s the neatest fix?
Pick one answer.
Try it
First, git add day2.css puts the file in the box. Now build the command that tucks the box into your last commit.
Tap the pieces in the right order.
Try it
Now do it for real. Add day2.css to the last commit.
- Empty
- 4 save points
- Add day 2 page
- Add style
- Add day 1 page
Hint
Typegit add day2.css, then git commit --amend --no-edit.Check
Check with git show --stat. Both files sit in one commit. Same message as before.
Predict
New story: you had pushed the commit already. What now?
Pick one answer.
You did it!
You can now add a forgotten file to your last commit.
Go deeper (optional)
Amend makes a brand-new commit with a new hash. That is why it’s only for commits you haven’t pushed. Forgot a file several commits ago? Just commit it now with a clear message. Simple wins.
Bahasa Melayu
Anda commit (titik simpan) halaman hari 2. Tapi fail gayanya masih atas meja! Ini berlaku pada semua orang. Ini cara selamat untuk keluar.
Anda belum push. Apa cara paling kemas?
Mula-mula, git add day2.css masukkan fail ke dalam kotak. Sekarang bina arahan yang selitkan isi kotak ke commit terakhir.
Sekarang buat betul-betul. Tambah day2.css ke commit terakhir.
git add day2.css, kemudian git commit --amend --no-edit.Semak dengan git show --stat. Kedua-dua fail dalam satu commit. Mesej sama seperti tadi.
Cerita baru: anda dah push commit itu. Sekarang apa?
Kini anda boleh tambah fail yang terlupa ke commit terakhir.
You finished this before. Practice is always welcome!
Official docs: git commit --amend · git add
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?