The repo is slow to clone because someone committed a 1 GB dataset two years ago and deleted it later. How do you shrink it?
IntermediateScenarioRebase, Cherry-pick and History Rewriting
Answer
Situation read → Deleting a file in a later commit leaves it in history forever.
What I'd do →
- Find big blobs:
git rev-list --objects --all | git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' | sort -k3 -n -r | head. - On a fresh mirror clone:
git filter-repo --path data/big.csv --invert-paths. - Force-push all refs, then have everyone re-clone.
- Ask GitHub Support to run garbage collection on cached views if needed.
Why → Only rewriting history removes the blob, and that changes SHAs for everything after it.
Interview tip → Plan the re-clone communication. Open PRs will have to be recreated.
More on Rebase, Cherry-pick and History Rewriting
Your PR branch has ten commits like "wip", "fix typo", "oops". How do you clean it up before review?BeginnerYou want the database migration commit to come before the code that uses it.BeginnerA critical fix on `main` must go to the `release/4.1` branch only.BeginnerYou must backport a feature made of 6 commits, including one merge commit.IntermediateBranch B was built on top of branch A. A was squash-merged into `main`, and now B shows A's commits again.IntermediateDuring review you get ten small change requests on old commits. How do you apply them cleanly?Intermediate