How can I find/identify large commits in Git history?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
“Large commit” can mean two different things in Git: a commit that changes many lines, or a commit that introduces large blob objects into the repository. Those are related but not identical, so the first step is deciding whether you care about review size, repository bloat, or both.
Measure Large Diffs With git log
If your goal is to find commits that were hard to review because they changed many files or lines, use diff statistics.
That prints each commit followed by a short summary such as files changed, insertions, and deletions. For a more focused view, include the hash and sort manually.
This approach is useful when you want to identify oversized code review changes, squashed refactors, or vendor drops. It does not tell you how much storage the commit added to the repository packfiles.
Find Large Stored Objects
Repository size problems usually come from large blobs, not from line counts. A binary file added once may barely show up in diff stats but still make clones expensive.
To find the largest objects reachable from history, list object IDs, inspect their sizes, and sort them.
Related reading
- How can I fix a reverted git commit?
- How can I fix the Git error object file ... is empty?
- How can I fully delete a Git repository created with init?
- How can I fully delete a Git repository created with init?
- How can I generate a Git patch for a specific commit?
- How can I get a list of Git branches, ordered by most recent commit?
- How can I get my C code to automatically print out its Git version hash?
- How can I get the assembly file version
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseNo course covers this one yet
Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.
Build my courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.