git filter-repo is a versatile tool for rewriting history.
git-filter-repo destructively rewrites history (unless --analyze or --dry-run are given) according to specified rules.
It refuses to do any rewriting unless either run from a clean fresh clone, or --force was given.
While most users will probably just use filter-repo as a simple command line tool (and likely only use a few of its flags), at its core filter-repo contains a library for creating history rewriting tools.
This is free and open source software.
Key Features
- Several different types of history rewrites are possible; examples include (but are not limited to):
- Stripping large files (or large directories or large extensions).
- Stripping unwanted files by path.
- Extracting wanted paths and their history (stripping everything else).
- Restructuring the file layout (such as moving all files into a subdirectory in preparation for merging with another repo, making a subdirectory become the new toplevel directory, or merging two directories with independent filenames into one directory).
- Renaming tags (also often in preparation for merging with another repo).
- Replacing or removing sensitive text such as passwords.
- Making mailmap rewriting of user names or emails permanent.
- Making grafts or replacement refs permanent.
- Rewriting commit messages.
- Additionally, several concerns are handled automatically (many of these can be overridden, but they are all on by default):
- Rewriting (possibly abbreviated) hashes in commit messages to refer to the new post-rewrite commit hashes.
- Pruning commits which become empty due to the above filters (also handles edge cases like pruning of merge commits which become degenerate and empty).
- Creating replace-refs for old commit hashes, which if manually pushed and fetched will allow users to continue to refer to new commits using (unabbreviated) old commit IDs.
- Stripping of original history to avoid mixing old and new history.
- Repacking the repository post-rewrite to shrink the repo for the user.
- Safety mechanism:
- Abort if run from a repo that is not a fresh clone (to prevent accidental data loss from rewriting local history that doesn’t exist anywhere else).
- Option to analyze a repository and generate reports that can be useful in determining what to filter (or in determining whether a separate filtering command was successful).
Website: github.com/newren/git-filter-repo
Support:
Developer: Elijah Newren
License: MIT License

git-filter-repo is written in Python. Learn Python with our recommended free books and free tutorials.
Related Software
| Git Tools for Diff Review and Repository History | |
|---|---|
| difftastic | Structural diff tool that compares files based on their syntax |
| git-filter-repo | Quickly rewrite git repository history |
| onefetch | Displays information about a local Git repository |
| git-stats | Local git statistics including GitHub-like contributions calendars |
| diff-so-fancy | Attractive diffs with diff-highlight and more |
| BFG Repo-Cleaner | Clean unwanted data from Git repository history |
| git-delta | Viewer for git and diff output |
| gitlogue | Cinematic Git commit replay tool |
| git-quick-stats | Access various statistics in a git repository |
| git-who | Command-line Git analysis tool |
| git-standup | Recall what you did on the last working day |
| git-of-theseus | Analyze how a Git repo grows over time |
| git-sizer | Compute various size metrics for a git repository |
| diffnav | Git diff pager based on delta but with a file tree, à la GitHub |
| critique | Terminal UI for reviewing git diffs |
| git-big-picture | Visualization tool for Git repositories |
| hercules | Gain advanced insights from Git repository history |
| keifu | TUI that visualizes Git commit graphs |
| git-fame | Git repository collaborators sorted by contributions |
| needle | Highlights GitHub PRs |
| mergiraf | Git merge driver |
| git-history | Analyze Git history using SQLite |
| ec | Terminal Git mergetool |
| diffr | Word-by-word diff highlighting utility |
| git-scope | Fast TUI dashboard to view the git status of all your repositories |
| mamediff | Manages unstaged and staged Git diffs |
| deadbranch | Keep Git repositories tidy |
| GitTop | Lightweight desktop client for GitHub notifications |
| git-heatmap | Generates a customizable heatmap |
Read our verdict in the software roundup.
Explore our comprehensive directory of recommended free and open source software. Our carefully curated collection spans every major software category.This directory is part of our ongoing series of informative articles for Linux enthusiasts. It features hundreds of detailed reviews, along with open source alternatives to proprietary solutions from major corporations such as Google, Microsoft, Apple, Adobe, IBM, Cisco, Oracle, and Autodesk. You’ll also find interesting projects to try, hardware coverage, free programming books and tutorials, and much more. Discovered a useful open source Linux program that we haven’t covered yet? Let us know by completing this form. |

