git-filter-repo Rewrite Git history
Light · Postcard
102 × 152 mm · PDF
Dark · Postcard
102 × 152 mm · PDF
Ink saver · Postcard
102 × 152 mm · PDF
Light · A4 landscape
297 × 210 mm · PDF
Dark · A4 landscape
297 × 210 mm · PDF
Ink saver · A4 landscape
297 × 210 mm · PDF
Light · A3 landscape
420 × 297 mm · PDF
Dark · A3 landscape
420 × 297 mm · PDF
Ink saver · A3 landscape
420 × 297 mm · PDF
Start here
git clone <url> <dir>
git filter-repo --analyze
git filter-repo --path <path>
git filter-repo --path <path> --invert-paths
git filter-repo --subdirectory-filter <dir>
git filter-repo --replace-text <file>
git filter-repo --strip-blobs-bigger-than 10M
git remote add origin <url>
Concepts
- Fresh clone throwaway copy
- Rewritten history new hashes, origin removed
- Check result log, ls-files
- New remote collaborators re-clone
Analyze
git filter-repo --analyze
git clone --no-local <src> <dst>
git filter-repo --force
git filter-repo --dry-run
git filter-repo --quiet
git filter-repo --debug
Select paths
--path <path>
--path <dir>/ --path <file>
--invert-paths--path-glob '<glob>'
--path-regex '<regex>'
--use-base-name--paths-from-file <file>
--refs <ref>
Restructure
--subdirectory-filter <dir>
--to-subdirectory-filter <dir>
--path-rename <old>:<new>
--tag-rename <old>:<new>
Content and messages
--replace-text <file>
--replace-message <file>
--strip-blobs-bigger-than <size>
--strip-blobs-with-ids <file>
--mailmap <file>
--use-mailmap--sensitive-data-removal
--preserve-commit-hashes
Pruning and callbacks
--prune-empty always|auto|never
--prune-degenerate always|auto|never
--partial--source <src> --target <dst>
--filename-callback '<python>'
--message-callback '<python>'
--name-callback '<python>'
--email-callback '<python>'
--commit-callback '<python>'
--refname-callback '<python>'
After the rewrite
git remote add origin <url>
git push --force --all
git push --force --tags
git log --oneline --stat
git ls-filesRecipes
git clone --no-local mono libcd libgit filter-repo --subdirectory-filter libs/core
git clone <url> clean && cd cleangit filter-repo --path secrets.env --invert-pathsgit remote add origin <url>git push --force --all
# expressions.txtliteral:AKIAEXAMPLE123==>***REMOVED***regex:password=\w+==>password=***REMOVED***git filter-repo --replace-text expressions.txt
git filter-repo --analyzeless .git/filter-repo/analysis/blob-shas-and-paths.txtgit filter-repo --strip-blobs-bigger-than 10M



