BM: Baca dalam Bahasa Melayu
World 10: Deep Git
Submodules vs subtrees
You will learn: two ways to keep another repo inside yours, and when to pick each.
The problem
Two shop apps use the same kuih-menu code, from its own repo. You fix a bug in it. How do both apps get the fix?
Pick one answer.
Watch
A submodule: Another repo inside your repo, linked at one exact commit. is a repo inside your repo. Your repo keeps a link: the URL and one exact commit.
Try it
Build the command that clones the app and its submodules at once.
Tap the pieces in the right order.
Predict
Mei clones the app without --recurse-submodules. What is in the menu folder?
Pick one answer.
Watch
A subtree: Another repo's files copied into a folder of your repo, as normal files. copies the other repo’s files into a folder. They become normal files in your repo. Teammates need nothing extra.
Check
Submodule or subtree? Sort each fact.
Drag a card into a box. Or tap the card, then tap the box.
You did it!
You can now pick a submodule or a subtree, and explain why.
Go deeper (optional)
git submodule update --remote moves a submodule to the newest commit of its branch. Then commit that change. git subtree pull --prefix=menu <url> main --squash brings in new menu work. git subtree lives in Git’s contrib area, so check git subtree -h first. Sometimes a package manager is simpler than both.
Bahasa Melayu
Dua aplikasi kedai guna kod kuih-menu yang sama, daripada repo sendiri. Anda baiki satu pepijat di situ. Macam mana kedua-dua aplikasi dapat pembaikan itu?
Submodule ialah repo di dalam repo anda. Repo anda simpan pautan: URL dan satu commit yang tepat.
Bina arahan yang clone aplikasi itu bersama submodulenya, sekali gus.
Mei clone aplikasi itu tanpa --recurse-submodules. Apa yang ada dalam folder menu?
Subtree salin fail repo lain ke dalam satu folder. Fail itu jadi fail biasa dalam repo anda. Rakan sepasukan tak perlu buat apa-apa tambahan.
Submodule atau subtree? Susun setiap fakta.
Kini anda boleh pilih submodule atau subtree, dan terangkan sebabnya.
You finished this before. Practice is always welcome!
Official docs: git submodule · gitsubmodules · git clone (--recurse-submodules)
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?