Python Advanced Remotes, Garbage Collection (git gc) & Maintenance
Over years of development, repositories accumulate stale remote-tracking references and loose uncompressed objects. git fetch --prune cleans up local references to deleted remote branches, and git gc (Garbage Collection) packs loose objects into compressed packfiles for blazing performance.
"git gc is like defragmenting your hard drive and taking out the recycling bin: consolidating loose papers into tightly bound archive binders to free up disk space and speed up search indexing."
Deep Dive: How It Works
git fetch --prune: Deletes local tracking branches (origin/foo) that have been deleted on the remote server.
git gc --aggressive: Deeply packs objects and optimizes index delta compression.
git count-objects -v: Reports detailed statistics on loose objects, packfiles, and disk size.
Syntax Blueprint
git fetch --prune origin git count-objects -v git gc --auto
Prune deleted remote references, inspect object database size, and pack repository storage.
Core Rules to Remember



Common Beginner Traps & How to Fix Them
Accumulating hundreds of ghost tracking branches after teammate PRs are merged and deleted.Why it happens: Standard git fetch only adds new branches and does not delete removed remote branches.
How to fix: Always fetch with --prune: git fetch --prune.
Live Interactive Example
Hit Run Code to see it liveYour Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Enable Global Fetch Pruning
Configure global automatic fetch pruning with "git config --global fetch.prune true".
Verify setting with "git config fetch.prune".
Finished reading and practicing?
Mark this lesson as completed to update your course progress.