Git Clients

git-filter-repo – quickly rewrite git repository history

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 options

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
difftasticStructural diff tool that compares files based on their syntax
git-filter-repoQuickly rewrite git repository history
onefetchDisplays information about a local Git repository
git-statsLocal git statistics including GitHub-like contributions calendars
diff-so-fancyAttractive diffs with diff-highlight and more
BFG Repo-CleanerClean unwanted data from Git repository history
git-deltaViewer for git and diff output
gitlogueCinematic Git commit replay tool
git-quick-statsAccess various statistics in a git repository
git-whoCommand-line Git analysis tool
git-standupRecall what you did on the last working day
git-of-theseusAnalyze how a Git repo grows over time
git-sizerCompute various size metrics for a git repository
diffnavGit diff pager based on delta but with a file tree, à la GitHub
critiqueTerminal UI for reviewing git diffs
git-big-pictureVisualization tool for Git repositories
herculesGain advanced insights from Git repository history
keifuTUI that visualizes Git commit graphs
git-fameGit repository collaborators sorted by contributions
needleHighlights GitHub PRs
mergirafGit merge driver
git-historyAnalyze Git history using SQLite
ecTerminal Git mergetool
diffrWord-by-word diff highlighting utility
git-scopeFast TUI dashboard to view the git status of all your repositories
mamediffManages unstaged and staged Git diffs
deadbranchKeep Git repositories tidy
GitTopLightweight desktop client for GitHub notifications
git-heatmapGenerates a customizable heatmap

Read our verdict in the software roundup.


Best Free and Open Source Software 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.
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted