Documentation Index
Fetch the complete documentation index at: https://mintlify.com/newren/git-filter-repo/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Basic filtering operations allow you to clean up your repository by removing unwanted files, extracting specific paths, or restructuring your project layout. These are the most common use cases for git-filter-repo.Path-Based Filtering
Keep Specific Files or Directories
To keep only specific paths in your repository history:All file paths are relative to the repository root.
Remove Specific Files
Use--invert-paths to keep everything except the specified paths:
secrets.txt and config/passwords.yml from all history.
Combining Include and Exclude
Run filter-repo multiple times to combine inclusion and exclusion filters:Pattern Matching
Glob Patterns
Use glob patterns for flexible matching:Regular Expressions
For more complex matching, use regex patterns:Base Name Matching
Match on filename only (not full path):--use-base-name is incompatible with --path-rename and directory matching.Subdirectory Operations
Extract Subdirectory as Root
Make a subdirectory the new repository root:- Before
- Command
- After
Move Everything to Subdirectory
Place all repository contents under a new directory:- Before
- Command
- After
Path Shortcuts
Paths from File
For extensive filtering, list all paths in a file:literal:(default) for exact matchesglob:for glob patternsregex:for regular expressions- Use
==>to specify renames
Generate Paths from Current Files
Keep only currently tracked files (delete historical files):Analysis Before Filtering
Analyze your repository to help decide what to filter:.git/filter-repo/analysis/:
- blob-shas-and-paths.txt - Files by size
- path-deleted-sizes.txt - Previously deleted large files
- extensions-all-sizes.txt - Size by file extension
- directories-all-sizes.txt - Size by directory
- renames.txt - File rename history
Common Examples
Remove Large Files
Extract Specific Modules
Clean Up .DS_Store Files
- Option 1: Base Name
- Option 2: Glob
Important Notes
Renames Are Not FollowedIf a file was renamed, specify both old and new paths:
Next Steps
- Learn about Path Renaming for restructuring
- Explore Content Filtering for text replacement
- See Advanced Filtering for complex operations
