Git gc और Maintenance
In this page:
git count-objects -v
git gc [--prune=now]
Git Garbage Collection क्या है?
जैसे-जैसे आप files modify और delete करते हैं, Git loose, unreferenced objects और legacy history fragments जमा करता है। Garbage collection इन files को packed files में compress करता है, repository size और speed optimize करते हुए।
उदाहरण: What is Git Garbage Collection?
git count-objects -v
git gc चलाना
git gc loose objects को compressed pack files में bundle करता है और अब किसी से referenced न होने वाले objects हटाता है, .git directory छोटा करते हुए और history scan करने वाले operations को तेज़ करते हुए — ज़्यादातर repositories को इसे manually चलाने की कभी ज़रूरत नहीं क्योंकि Git कुछ thresholds के बाद automatically इसे trigger करता है।
उदाहरण: Running git gc
git gc
Loose Objects को Pruning करना
एक discarded commit, एक aborted rebase, या एक deleted branch से बचे objects तब तक रहते हैं जब तक वे pruned न हों — git prune किसी भी branch, tag, या reflog से अब reachable न होने वाला कोई भी object हटा देता है, उनके इस्तेमाल की गई disk space free करते हुए।
उदाहरण: Pruning Loose Objects
git prune
Repository Health Check करना
git fsck repository के database में हर object corruption या dangling references (ऐसे objects जो exist करते हैं लेकिन कोई उन्हें point नहीं करता) के लिए check करते हुए चलता है, जो वह tool है जिस तक पहुँचना है अगर एक repository अजीब behave करना शुरू करे और आपको लगे कि underlying data खुद damaged है।
उदाहरण: Checking Repository Health
git fsck
Automated Background Maintenance
Git 2.30 से, git maintenance background tasks — prefetching, incremental repacking, loose-object cleanup — को periodically चलने के लिए schedule कर सकता है बिना आपको खुद gc invoke करना याद रखे, बड़ी, long-lived repositories को manual upkeep के बिना तेज़ रखते हुए।
उदाहरण: Automated Background Maintenance
git maintenance start
git gc --prune=nowचलाना और recoverable commits रखने की उम्मीद करना, जबकि यह unreferenced objects permanently हटा देता है।- habit से अक्सर
git gcचलाना, जबकि Git ज़रूरत पड़ने पर पहले से automatically इसे चलाता है। - बड़े binaries commit करने के बाद
git gcसे repository के काफी छोटा होने की उम्मीद करना, जबकि files history में रहती हैं।
Chapter Quiz — Complete all 8 topics to unlock
0/8 topics done
Complete these topics first: