Skip to main content
Before rewriting repository history, it’s essential to understand what’s in your repository. git-filter-repo includes a powerful analysis mode that generates detailed reports.

Basic Analysis

Generate a comprehensive analysis report:
1

Clone the repository

2

Run analysis

This creates reports in the .git/filter-repo/analysis/ directory without modifying your repository.
3

Review the reports

Generated reports:
  • blob-shas-and-paths.txt - All blob hashes and their paths
  • directories-all-sizes.txt - Directory sizes across all history
  • directories-deleted-sizes.txt - Size of deleted directories
  • extensions-all-sizes.txt - File types and their sizes
  • extensions-deleted-sizes.txt - Deleted files by extension
  • path-all-sizes.txt - Individual file sizes
  • path-deleted-sizes.txt - Deleted files
  • renames.txt - File rename history
The analysis mode does not modify your repository. It’s safe to run multiple times.

Understanding the Reports

Largest Files Report

View the biggest files in history:
Output format:
This shows:
  • Unpacked size: Actual file size
  • Packed size: Compressed size in Git
  • Date deleted: When file was removed (or <present> if still exists)
  • Path name: File location

Deleted Files Report

Find large files that were deleted but still bloat history:
These are prime candidates for removal since they:
  • No longer exist in the current codebase
  • Still take up space in clones
  • Slow down clone operations

Extension Analysis

See which file types consume the most space:
Example output:
This helps identify:
  • Binary files that shouldn’t be in Git
  • Large media files better suited for Git LFS
  • Compressed files that could be removed

Directory Size Report

Identifies which directories contribute most to repository size.

Acting on Analysis Results

Once you’ve analyzed your repository, you can clean it up:

Remove large deleted files

1

Identify files to remove

Review deleted files:
2

Create removal list

Create ../files-to-remove.txt with paths of files to delete:
3

Remove the files

Remove files by extension

Remove all files of a certain type:

Remove large directories

Advanced Analysis Techniques

Find duplicate files

The blob-shas-and-paths.txt report shows all blob hashes. Look for identical hashes:

Track file renames

The renames.txt report shows file rename history:
Example output:

Analyze by time period

Combine analysis with Git log to find when large files were added:

Continuous Monitoring

Pre-commit checks

Prevent large files from being committed:

Regular analysis

Run analysis periodically to catch bloat early:

Interpreting Size Differences

Unpacked vs Packed Size

  • Unpacked: Actual file size on disk
  • Packed: Compressed size in Git objects
  • Large difference indicates good compression
  • Small difference suggests already-compressed files (zip, jpg, etc.)

Current vs Historical Size

Compare current repository size to historical:
Large discrepancy indicates deleted files still bloating history.

Example: Complete Repository Audit

1

Run analysis

2

Generate summary report

3

Identify cleanup targets

Based on the reports:
  • Large deleted files: Remove from history
  • Binary files: Consider Git LFS
  • Build artifacts: Should be in .gitignore
  • Old dependencies: Safe to remove
4

Plan cleanup

Create a cleanup plan:

Best Practices

  1. Run analysis before filtering: Always analyze before making changes
  2. Keep reports: Save analysis reports for historical reference
  3. Focus on deleted files: Biggest wins come from removing deleted large files
  4. Check extensions: Identify file types that shouldn’t be in Git
  5. Compare before/after: Run analysis again after cleanup to verify

Troubleshooting Analysis

Analysis is slow

For very large repositories:

Reports are too large

Filter reports to focus on significant files:

Missing expected files

Ensure you’re analyzing all branches: