BM: Baca dalam Bahasa Melayu
World 3: Parallel Universes
Clean up branches
You will learn: which branches are safe to delete, and how.
The problem
Your list of branches keeps growing. Old notes everywhere! Which ones can you throw away safely?
Watch
git branch -d about peels off the note. The commits stay safe, because main already has them.
Try it
git branch --merged lists notes whose work is already in your branch. Tap the ones you can delete.
Tap each merged note you can delete. Not the one you are on!
0 of 2 found
Hint
The star marks your own branch. Leave that one.Try it
Delete the merged notes about and dark-mode. Keep old-idea.
Hint
One note at a time:git branch -d about.Predict
old-idea was never merged. You run git branch -d old-idea. What happens?
Pick one answer.
Watch
Sure you don’t need it? git branch -D (capital D) deletes it anyway. Careful: its commit loses its last note.
Check
What does git branch -d say?
Drag a card into a box. Or tap the card, then tap the box.
You did it!
You can now tidy your branches without losing work.
Go deeper (optional)
git branch --no-merged lists notes with work still waiting. Deleted a note by mistake? git reflog still knows the commit. Then git branch old-idea <hash> sticks the note back on.
Bahasa Melayu
Senarai branch anda makin panjang. Nota lama di mana-mana! Yang mana boleh dibuang dengan selamat?
git branch -d about tanggalkan nota itu. Commit kekal selamat, sebab main dah ada semuanya.
git branch --merged senaraikan nota yang kerjanya dah masuk ke branch anda. Ketik yang boleh dipadam.
Padam nota yang dah di-merge, about dan dark-mode. Kekalkan old-idea.
git branch -d about.old-idea tak pernah di-merge. Anda jalankan git branch -d old-idea. Apa jadi?
Pasti tak perlukannya? git branch -D (D besar) padam juga. Hati-hati: commitnya hilang nota terakhir.
Apa kata git branch -d?
Kini anda boleh kemas branch tanpa hilang kerja.
You finished this before. Practice is always welcome!
Official docs: git branch (-d, -D, --merged)
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?