BM: Baca dalam Bahasa Melayu
World 10: Deep Git
Packfiles, gc and maintenance
You will learn: how Git keeps a big history small and fast, mostly by itself.
The problem
Your project has 10,000 commits. Each one made new objects. Is .git now a mess of tiny files?
Pick one answer.
Watch
Git squeezes many objects into one packfile: One file that holds many objects, squeezed together. Similar versions are saved as small differences.. Tap each step to see how.
Tap each point on the timeline.
Predict
A big file has 10 versions. Each version changed one line. In a packfile, what takes the space?
Pick one answer.
Watch
git gc is garbage collection (gc): Git tidying up: packing objects and throwing away ones nothing can reach.. It packs objects and drops junk that nothing can reach. git count-objects -vH shows the size. Git also tidies a little by itself.
Try it
gc only throws away objects that nothing can reach. Which ones does it keep?
Drag a card into a box. Or tap the card, then tap the box.
Watch
Big repo you use every day? git maintenance start tidies it in the background. Your computer runs the jobs on a schedule.
Check
Good habit, or needs work? Swipe each one.
Swipe right for good, left for needs work. Or use the buttons.
Let Git pack objects for you
You did it!
You can now explain packfiles and let Git tidy up for you.
Go deeper (optional)
Packfiles live in .git/objects/pack. git gc --prune=now drops unreachable objects at once, with no grace time. git maintenance stop turns the background jobs off. git maintenance run --task=gc runs one job now. Git 3.0 removes the old git pack-redundant command.
Bahasa Melayu
Projek anda ada 10,000 commit (titik simpan). Setiap satu buat objek baru. Adakah .git kini bersepah dengan fail kecil?
Git mampatkan banyak objek ke dalam satu packfile. Ketik setiap langkah untuk tengok caranya.
Satu fail besar ada 10 versi. Setiap versi ubah satu baris. Dalam packfile, apa yang guna ruang?
git gc ialah kutipan sampah (garbage collection). Ia padatkan objek dan buang sampah yang tiada siapa boleh capai. git count-objects -vH tunjuk saiznya. Git juga mengemas sedikit sendiri.
gc cuma buang objek yang tiada apa-apa boleh capai. Yang mana ia simpan?
Repo besar yang anda guna setiap hari? git maintenance start kemaskannya di belakang tabir. Komputer anda jalankan kerja itu ikut jadual.
Tabiat baik, atau perlu dibaiki? Leret setiap satu.
Kini anda boleh terangkan packfile dan biar Git mengemas untuk anda.
You finished this before. Practice is always welcome!
Official docs: git gc · git maintenance · git count-objects · gitglossary (pack)
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?