BM: Baca dalam Bahasa Melayu
World 3: Parallel Universes
Put work aside with stash
You will learn: to park half-done work, switch branches, and get it back.
The problem
Dark mode is half done. Then: an urgent fix on main! Git won’t let you switch. Now what?
Watch
git stash puts unfinished changes in a drawer. Your folder is clean again, so you can switch. The drawer is the stash: A drawer for unfinished changes. Your folder gets clean; take them back later..
Try it
Put your work in the drawer. Then switch to main.
- Empty
- 4 save points
- Start dark mode
- Add style
- Add day 1 page
Hint
Two commands:git stash, then git switch main.Watch
Done with the fix? git stash pop takes the newest work out of the drawer. It lands in your folder again.
Try it
You fixed main. Go back to dark-mode and take your work out of the drawer.
- Empty
- Empty
- 4 save points
- Fix home page title
- Add style
- Add day 1 page
Hint
Switch first. Thengit stash pop.Predict
You stash twice, then pop once. Which work comes out?
Pick one answer.
Check
Here is a drawer with two entries.
Tap the entry that git stash pop takes out.
0 of 1 found
You did it!
You can now put work aside and get it back later.
Go deeper (optional)
git stash -u also takes new, untracked files. git stash push -m "note" adds a label. git stash apply puts work back but keeps a copy in the drawer. git stash drop throws one away for good. A pop can clash with newer changes. Then the markers say Updated upstream and Stashed changes.
Bahasa Melayu
Tema gelap baru separuh siap. Tiba-tiba: ada pembaikan segera di main! Git tak benarkan anda tukar. Sekarang macam mana?
git stash simpan perubahan yang belum siap dalam laci. Folder anda bersih semula, jadi anda boleh tukar branch. Laci itu ialah stash (simpanan sementara).
Simpan kerja anda dalam laci. Kemudian tukar ke main.
git stash, kemudian git switch main.Dah siap pembaikan? git stash pop keluarkan kerja paling baru dari laci. Ia kembali ke folder anda.
Anda dah baiki main. Kembali ke dark-mode dan keluarkan kerja anda dari laci.
git stash pop.Anda stash dua kali, kemudian pop sekali. Kerja mana yang keluar?
Ini laci dengan dua entri.
Kini anda boleh simpan kerja sementara dan ambil semula kemudian.
You finished this before. Practice is always welcome!
Official docs: git stash
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?